contentLister/inc/erMSDisk.h File Reference

#include "stack.h"

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define CMD_LEN   32
#define PROCFS_MOUNT_FILE   "/proc/mounts"

Enumerations

enum  expMemType_e {
  expMain = 0, expMMC, expUSB, expCF,
  expUndefined
}

Functions

void erMSDiskInit ()
void erStartMSDiskApp ()
void erStopMSDiskApp ()
int erMSDiskSetConnected (int connected)
expMemType_e get_exported_memory_type (void)
expMemType_e get_memory_type_used ()
void erMSDisk_storage_changed (st_ContentType_e storageType, gboolean storagePresent)
void erMSDisk_handle_reread_settings ()


Define Documentation

#define CMD_LEN   32

Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.

Definition at line 28 of file erMSDisk.h.

#define PROCFS_MOUNT_FILE   "/proc/mounts"

Definition at line 29 of file erMSDisk.h.


Enumeration Type Documentation

Enumerator:
expMain 
expMMC 
expUSB 
expCF 
expUndefined 

Definition at line 31 of file erMSDisk.h.

00032 {
00033     expMain = 0,
00034     expMMC,
00035     expUSB,
00036     expCF,
00037     expUndefined
00038 } expMemType_e;


Function Documentation

void erMSDisk_handle_reread_settings (  ) 

Definition at line 334 of file erMSDisk.c.

00335 {
00336     // Re-read export settings from registry
00337     g_export_memory_type = read_exported_memory_type();
00338 }

Here is the call graph for this function:

void erMSDisk_storage_changed ( st_ContentType_e  storageType,
gboolean  storagePresent 
)

Definition at line 285 of file erMSDisk.c.

00286 {
00287     CL_LOGPRINTF("storageType = %d, storagePresent = %d", storageType, storagePresent);
00288 
00289     // Convert st_ContentType_e to expMemType_e
00290     expMemType_e storage_type = expUndefined;
00291     switch (storageType)
00292     {
00293         case st_StorageTypeCF:
00294             storage_type = expCF;
00295             break;
00296         case st_StorageTypeSD:
00297             storage_type = expMMC;
00298             break;
00299         case st_StorageTypeUSB:
00300             storage_type = expUSB;
00301             break;
00302         default:
00303             break;
00304     }
00305 
00306     if (getListerState() == STATE_USB_CONNECTED)
00307     {
00308         // Connected to PC
00309         if (storagePresent == FALSE)
00310         {
00311             // Card plug out event
00312             if (storage_type == g_memory_type_used)
00313             {
00314                 // The memory type we are using is plugged out
00315                 CL_WARNPRINTF("WARNING! Card is plugged out when connected to PC.");
00316 
00317                 // Stop msdisk application
00318                 erStopMSDiskApp();
00319                 listerHideUSBScreen();
00320                 setListerState(STATE_NORMAL);
00321             }
00322             else
00323             {
00324                 // Another type of memory is plugged out, don't care
00325             }
00326         }
00327     }
00328     else if (storage_type == g_export_memory_type)
00329     {   
00330         erStartMSDiskApp();
00331     }
00332 }

Here is the call graph for this function:

void erMSDiskInit (  ) 

Definition at line 106 of file erMSDisk.c.

Here is the call graph for this function:

int erMSDiskSetConnected ( int  connected  ) 

Definition at line 181 of file erMSDisk.c.

00182 {
00183     CL_WARNPRINTF("connected = %d", connected);
00184 
00185     if (connected == 1)
00186     {
00187         listerShowUSBScreen();
00188         setListerState(STATE_USB_CONNECTED);
00189 
00190 #ifdef ENABLE_CONFIG_EXPORT_IMPORT
00191         ctrl_export_config();
00192 #endif
00193 
00194         // For USB stick, if we umount USB memory before exporting it, it fails.
00195         // So just handle USB memory as an exeception, still don't know why.
00196         if (g_export_memory_type != expUSB)
00197         {
00198             erMSDiskDisconnectFlash();
00199         }
00200 
00201         return 0;
00202     }
00203     else if (connected == 0)
00204     {
00205         // Again, it can't work for USB stick...
00206         if (g_export_memory_type != expUSB)
00207         {
00208             erMSDiskReconnectFlash();
00209         }
00210 
00211         listerHideUSBScreen();
00212         setListerState(STATE_NORMAL);
00213 
00214 #ifdef ENABLE_CONFIG_EXPORT_IMPORT
00215         ctrl_handle_import_config();
00216 #endif
00217 
00218         mdsRecreateArchives(st_StorageTypeMain);
00219         mdsRecreateArchives(st_StorageTypeCF);
00220         mdsRecreateArchives(st_StorageTypeSD);
00221         mdsRecreateArchives(st_StorageTypeUSB);
00222         
00223         return 0;
00224     }
00225     else
00226     {
00227         return -1;
00228     }
00229 }

Here is the call graph for this function:

void erStartMSDiskApp (  ) 

Definition at line 139 of file erMSDisk.c.

00140 {
00141     char cmd[CMD_LEN];
00142     expMemType_e memory_type_new = expMain;  // memory to be exported, default is internal memory
00143 
00144     CL_WARNPRINTF("entry: g_export_memory_type [%d] g_memory_type_used [%d]", g_export_memory_type, g_memory_type_used);
00145 
00146     // Use export type only when mounted
00147     if ( is_device_mounted(dev[g_export_memory_type]) )
00148     {
00149         memory_type_new = g_export_memory_type;
00150     }
00151 
00152     if (g_memory_type_used == memory_type_new)
00153     {
00154         ;  // msdisk application already running on required memory type: do nothing
00155     }
00156     else
00157     {
00158         // Stop msdisk application if running
00159         if (g_memory_type_used != expUndefined)
00160         {
00161             erStopMSDiskApp();
00162         }
00163 
00164         // Start msdisk application
00165         g_memory_type_used = memory_type_new;
00166         snprintf(cmd, sizeof(cmd), "sync ; msdisk %s &", dev[g_memory_type_used]);
00167         CL_WARNPRINTF("-- starting msdisk [%s]", cmd);
00168         system(cmd);
00169     }
00170 }

Here is the call graph for this function:

void erStopMSDiskApp (  ) 

Definition at line 172 of file erMSDisk.c.

00173 {
00174     // TODO: The better solution is using fork/exec and then sending SIGTERM signal
00175     CL_WARNPRINTF("-- stopping msdisk");
00176     system("killall msdisk; sync; sync;");
00177 
00178     g_memory_type_used = expUndefined;
00179 }

expMemType_e get_exported_memory_type ( void   ) 

Definition at line 54 of file erMSDisk.c.

00055 {
00056     return g_export_memory_type;
00057 }

expMemType_e get_memory_type_used (  )  [inline]

Definition at line 59 of file erMSDisk.c.

00060 {
00061     return g_memory_type_used;
00062 }


Generated on Sun Dec 14 17:12:50 2008 by  doxygen 1.5.6