"Fossies" - the Fresh Open Source Software Archive

Member "gammu-1.42.0/include/gammu-statemachine.h" (3 Oct 2020, 7517 Bytes) of package /linux/privat/gammu-1.42.0.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "gammu-statemachine.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.41.0_vs_1.42.0.

    1 /**
    2  * \file gammu-statemachine.h
    3  * \author Michal Čihař
    4  *
    5  * State machine data.
    6  */
    7 #ifndef __gammu_statemachine_h
    8 #define __gammu_statemachine_h
    9 
   10 #ifdef  __cplusplus
   11 extern "C" {
   12 #endif
   13 
   14 /**
   15  * \defgroup StateMachine State machine
   16  * Generic state machine layer.
   17  */
   18 
   19 #include <gammu-types.h>
   20 #include <gammu-error.h>
   21 #include <gammu-inifile.h>
   22 
   23 /**
   24  * Callback function for logging.
   25  *
   26  * \param text Text to be printed, \n will be also sent (as a separate
   27  * message).
   28  * \param data Arbitrary logger data, as passed to \ref GSM_InitConnection_Log.
   29  *
   30  */
   31 typedef void (*GSM_Log_Function) (const char *text, void *data);
   32 
   33 /**
   34  * Private structure holding information about phone connection. Should
   35  * be allocated by \ref GSM_AllocStateMachine and freed by
   36  * \ref GSM_FreeStateMachine.
   37  *
   38  * \ingroup StateMachine
   39  */
   40 typedef struct _GSM_StateMachine GSM_StateMachine;
   41 
   42 #include <gammu-info.h>
   43 
   44 /**
   45  * Configuration of state machine.
   46  *
   47  * \ingroup StateMachine
   48  */
   49 typedef struct {
   50     /**
   51      * Model from config file
   52      */
   53     char Model[50];
   54     /**
   55      * Debug level
   56      */
   57     char DebugLevel[50];
   58     /**
   59      * Device name from config file
   60      */
   61     char *Device;
   62     /**
   63      * Connection type as string
   64      */
   65     char *Connection;
   66     /**
   67      * Synchronize time on startup?
   68      */
   69     gboolean SyncTime;
   70     /**
   71      * Lock device ? (Unix)
   72      */
   73     gboolean LockDevice;
   74     /**
   75      * Name of debug file
   76      */
   77     char *DebugFile;
   78     /**
   79      * Display something during start ?
   80      */
   81     gboolean StartInfo;
   82     /**
   83      * Should we use global debug file?
   84      */
   85     gboolean UseGlobalDebugFile;
   86     /**
   87      * Text for reminder calendar entry category in local language
   88      */
   89     char TextReminder[32];
   90     /**
   91      * Text for meeting calendar entry category in local language
   92      */
   93     char TextMeeting[32];
   94     /**
   95      * Text for call calendar entry category in local language
   96      */
   97     char TextCall[32];
   98     /**
   99      * Text for birthday calendar entry category in local language
  100      */
  101     char TextBirthday[32];
  102     /**
  103      * Text for memo calendar entry category in local language
  104      */
  105     char TextMemo[32];
  106     /**
  107      * Phone features override.
  108      */
  109     GSM_Feature PhoneFeatures[GSM_MAX_PHONE_FEATURES + 1];
  110     /**
  111      * Used to override default CNMI arguments for generic
  112      * AT protocol.
  113      */
  114      int CNMIParams[5];
  115 } GSM_Config;
  116 
  117 /**
  118  * Connection types definitions.
  119  */
  120 typedef enum {
  121     GCT_MBUS2 = 1,
  122     GCT_FBUS2,
  123     GCT_FBUS2DLR3,
  124     GCT_DKU2AT,
  125     GCT_DKU2PHONET,
  126     GCT_DKU5FBUS2,
  127     GCT_ARK3116FBUS2,
  128     GCT_FBUS2PL2303,
  129     GCT_FBUS2BLUE,
  130     GCT_FBUS2IRDA,
  131     GCT_PHONETBLUE,
  132     GCT_AT,
  133     GCT_BLUEGNAPBUS,
  134     GCT_IRDAOBEX,
  135     GCT_IRDAGNAPBUS,
  136     GCT_IRDAAT,
  137     GCT_IRDAPHONET,
  138     GCT_BLUEFBUS2,
  139     GCT_BLUEAT,
  140     GCT_BLUEPHONET,
  141     GCT_BLUEOBEX,
  142     GCT_FBUS2USB,
  143     GCT_BLUES60,
  144     GCT_PROXYGNAPBUS,
  145     GCT_PROXYFBUS2,
  146     GCT_PROXYAT,
  147     GCT_PROXYPHONET,
  148     GCT_PROXYOBEX,
  149     GCT_PROXYS60,
  150     GCT_NONE
  151 } GSM_ConnectionType;
  152 
  153 /**
  154  * Initiates connection with custom logging callback.
  155  *
  156  * \ingroup StateMachine
  157  *
  158  * \param s State machine data
  159  * \param ReplyNum Number of replies to await (usually 3).
  160  * \param log_function Logging function, see GSM_SetDebugFunction.
  161  * \param user_data User data for logging function, see GSM_SetDebugFunction.
  162  * \return Error code
  163  * \see GSM_SetDebugFunction
  164  */
  165 GSM_Error GSM_InitConnection_Log(GSM_StateMachine * s, int ReplyNum,
  166                  GSM_Log_Function log_function,
  167                  void *user_data);
  168 
  169 /**
  170  * Initiates connection.
  171  *
  172  * \ingroup StateMachine
  173  *
  174  * \param s State machine data
  175  * \param ReplyNum Number of replies to await (usually 3).
  176  * \return Error code
  177  */
  178 GSM_Error GSM_InitConnection(GSM_StateMachine * s, int ReplyNum);
  179 
  180 /**
  181  * Terminates connection.
  182  *
  183  * \ingroup StateMachine
  184  *
  185  * \param s State machine data
  186  * \return Error code
  187  */
  188 GSM_Error GSM_TerminateConnection(GSM_StateMachine * s);
  189 
  190 /**
  191  * Aborts current operation.
  192  *
  193  * This is thread safe call to abort any existing operations with the
  194  * phone.
  195  *
  196  * \ingroup StateMachine
  197  *
  198  * \param s State machine data
  199  * \return Error code
  200  */
  201 GSM_Error GSM_AbortOperation(GSM_StateMachine * s);
  202 
  203 /**
  204  * Attempts to read data from phone. This can be used for getting
  205  * status of incoming events, which would not be found out without
  206  * polling device.
  207  *
  208  * \ingroup StateMachine
  209  *
  210  * \param s State machine data
  211  * \param waitforreply Whether to wait for some event
  212  * \return Number of read bytes
  213  */
  214 int GSM_ReadDevice(GSM_StateMachine * s, gboolean waitforreply);
  215 
  216 /**
  217  * Detects whether state machine is connected.
  218  *
  219  * \ingroup StateMachine
  220  *
  221  * \param s State machine data
  222  * \return Whether phone is connected.
  223  */
  224 gboolean GSM_IsConnected(GSM_StateMachine * s);
  225 
  226 /**
  227  * Finds and reads gammu configuration file. The search order depends on
  228  * platform. On POSIX systems it looks for ~/.gammurc and then for
  229  * /etc/gammurc, on Windows for gammurc in Application data folder, then
  230  * in home and last fallback is in current driectory.
  231  *
  232  * \param result Ini file representation
  233  * \param force_config Forcing of custom path instead of autodetected
  234  * one (if NULL, autodetection is performed).
  235  *
  236  * \return Error code
  237  *
  238  * \ingroup StateMachine
  239  */
  240 GSM_Error GSM_FindGammuRC(INI_Section ** result, const char *force_config);
  241 
  242 /**
  243  * Processes gammu configuration.
  244  *
  245  * \param cfg_info Ini file representation.
  246  * \param cfg Where to store configuration.
  247  * \param num Number of section to read.
  248  * \return Whether we got valid configuration. Especially check for
  249  * ERR_USING_DEFAULTS.
  250  *
  251  * \ingroup StateMachine
  252  *
  253  * \see GSM_FallbackConfig
  254  */
  255 GSM_Error GSM_ReadConfig(INI_Section * cfg_info, GSM_Config * cfg, int num);
  256 
  257 /**
  258  * Gets gammu configuration from state machine. This actually returns
  259  * pointer to internal configuration storage, so you can use it also for
  260  * updating existing settings.
  261  *
  262  * \param s State machine data
  263  * \param num Number of section to read, -1 for currently used.
  264  * \return Pointer to configuration.
  265  *
  266  * \ingroup StateMachine
  267  */
  268 GSM_Config *GSM_GetConfig(GSM_StateMachine * s, int num);
  269 
  270 /**
  271  * Gets number of active gammu configurations.
  272  *
  273  * \param s State machine data
  274  * \return Number of sections.
  275  *
  276  * \ingroup StateMachine
  277  */
  278 int GSM_GetConfigNum(const GSM_StateMachine * s);
  279 
  280 /**
  281  * Gets number of active gammu configurations.
  282  *
  283  * \param s State machine data
  284  * \param sections Number of sections.
  285  *
  286  * \ingroup StateMachine
  287  */
  288 void GSM_SetConfigNum(GSM_StateMachine * s, int sections);
  289 
  290 /**
  291  * Allocates new clean state machine structure. You should free it then
  292  * by \ref GSM_FreeStateMachine.
  293  *
  294  * \return Pointer to state machine structure.
  295  *
  296  * \ingroup StateMachine
  297  */
  298 GSM_StateMachine *GSM_AllocStateMachine(void);
  299 
  300 /**
  301  * Frees state machine structure allocated by
  302  * \ref GSM_AllocStateMachine.
  303  *
  304  * \param s Pointer to state machine structure.
  305  *
  306  * \ingroup StateMachine
  307  */
  308 void GSM_FreeStateMachine(GSM_StateMachine * s);
  309 
  310 /**
  311  * Gets number of active gammu configurations.
  312  *
  313  * \param s State machine data
  314  * \return Connection type.
  315  *
  316  * \ingroup StateMachine
  317  */
  318 GSM_ConnectionType GSM_GetUsedConnection(GSM_StateMachine * s);
  319 
  320 /**
  321  * Installs applet required for configured connection to the phone.
  322  *
  323  * \param s State machine data.
  324  * \param ExtraPath Extra path where to search for installation data.
  325  * \param Minimal Whether to do minimal installation (eg. without support
  326  * libraries), useful for applet updates
  327  * \return Result of operation.
  328  *
  329  * \ingroup StateMachine
  330  */
  331 GSM_Error GSM_Install(GSM_StateMachine *s, const char *ExtraPath, gboolean Minimal);
  332 
  333 #ifdef  __cplusplus
  334 }
  335 #endif
  336 #endif
  337 
  338 /* Editor configuration
  339  * vim: noexpandtab sw=8 ts=8 sts=8 tw=72:
  340  */