1 /* (c) 2002-2004 by Marcin Wiacek & Michal Cihar */ 2 3 /** 4 * @file gsmstate.h 5 * @author Michal Čihař 6 * @author Marcin Wiacek 7 */ 8 9 /** 10 * \addtogroup StateMachine 11 * 12 * @{ 13 */ 14 15 #ifndef __gsm_state_h 16 #define __gsm_state_h 17 18 #include <time.h> 19 20 #include <gammu-file.h> 21 #include <gammu-info.h> 22 #include <gammu-config.h> 23 #include <gammu-keys.h> 24 #include <gammu-security.h> 25 #include <gammu-callback.h> 26 #include <gammu-settings.h> 27 #include <gammu-misc.h> 28 #include <gammu-category.h> 29 #include <gammu-backup.h> 30 #include <string.h> 31 32 typedef struct _GSM_User GSM_User; 33 34 #ifdef GSM_ENABLE_NOKIA3650 35 # include "phone/nokia/wd2/n3650.h" 36 #endif 37 #ifdef GSM_ENABLE_NOKIA650 38 # include "phone/nokia/dct3/n0650.h" 39 #endif 40 #ifdef GSM_ENABLE_NOKIA6110 41 # include "phone/nokia/dct3/n6110.h" 42 #endif 43 #ifdef GSM_ENABLE_NOKIA3320 44 # include "phone/nokia/dct4s40/n3320.h" 45 #endif 46 #ifdef GSM_ENABLE_NOKIA6510 47 # include "phone/nokia/dct4s40/6510/n6510.h" 48 #endif 49 #ifdef GSM_ENABLE_NOKIA7110 50 # include "phone/nokia/dct3/n7110.h" 51 #endif 52 #ifdef GSM_ENABLE_NOKIA9210 53 # include "phone/nokia/dct3/n9210.h" 54 #endif 55 #ifdef GSM_ENABLE_ATGEN 56 # include "phone/at/atgen.h" 57 #endif 58 #ifdef GSM_ENABLE_ALCATEL 59 # include "phone/alcatel/alcatel.h" 60 #endif 61 #ifdef GSM_ENABLE_ATOBEX 62 # include "phone/atobex/atobex.h" 63 #endif 64 #ifdef GSM_ENABLE_OBEXGEN 65 # include "phone/obex/obexgen.h" 66 #endif 67 #ifdef GSM_ENABLE_GNAPGEN 68 # include "phone/symbian/gnapgen.h" 69 #endif 70 #ifdef GSM_ENABLE_S60 71 # include "phone/s60/s60phone.h" 72 #endif 73 # include "phone/dummy/dummy.h" 74 75 #ifndef GSM_USED_MBUS2 76 # undef GSM_ENABLE_MBUS2 77 #endif 78 #ifndef GSM_USED_FBUS2 79 # undef GSM_ENABLE_FBUS2 80 #endif 81 #ifndef GSM_USED_FBUS2DLR3 82 # undef GSM_ENABLE_FBUS2DLR3 83 #endif 84 #ifndef GSM_USED_DKU2PHONET 85 # undef GSM_ENABLE_DKU2PHONET 86 #endif 87 #ifndef GSM_USED_DKU2AT 88 # undef GSM_ENABLE_DKU2AT 89 #endif 90 #ifndef GSM_USED_DKU5FBUS2 91 # undef GSM_ENABLE_DKU5FBUS2 92 #endif 93 #ifndef GSM_USED_FBUS2PL2303 94 # undef GSM_ENABLE_FBUS2PL2303 95 #endif 96 #ifndef GSM_USED_FBUS2BLUE 97 # undef GSM_ENABLE_FBUS2BLUE 98 #endif 99 #ifndef GSM_USED_FBUS2IRDA 100 # undef GSM_ENABLE_FBUS2IRDA 101 #endif 102 #ifndef GSM_USED_PHONETBLUE 103 # undef GSM_ENABLE_PHONETBLUE 104 #endif 105 #ifndef GSM_USED_AT 106 # undef GSM_ENABLE_AT 107 #endif 108 #ifndef GSM_USED_ALCABUS 109 # undef GSM_ENABLE_ALCABUS 110 #endif 111 #ifndef GSM_USED_IRDAPHONET 112 # undef GSM_ENABLE_IRDAPHONET 113 #endif 114 #ifndef GSM_USED_IRDAAT 115 # undef GSM_ENABLE_IRDAAT 116 #endif 117 #ifndef GSM_USED_IRDAOBEX 118 # undef GSM_ENABLE_IRDAOBEX 119 #endif 120 #ifndef GSM_USED_BLUEFBUS2 121 # undef GSM_ENABLE_BLUEFBUS2 122 #endif 123 #ifndef GSM_USED_BLUEOBEX 124 # undef GSM_ENABLE_BLUEOBEX 125 #endif 126 #ifndef GSM_USED_BLUEPHONET 127 # undef GSM_ENABLE_BLUEPHONET 128 #endif 129 #ifndef GSM_USED_BLUEAT 130 # undef GSM_ENABLE_BLUEAT 131 #endif 132 #ifndef GSM_USED_BLUEGNAPBUS 133 # undef GSM_ENABLE_BLUEGNAPBUS 134 #endif 135 136 #include "protocol/protocol.h" 137 #if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_DKU5FBUS2) || defined(GSM_ENABLE_FBUS2PL2303) 138 # include "protocol/nokia/fbus2.h" 139 #endif 140 #ifdef GSM_ENABLE_MBUS2 141 # include "protocol/nokia/mbus2.h" 142 #endif 143 #if defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_IRDAPHONET) || defined(GSM_ENABLE_BLUEPHONET) || defined(GSM_ENABLE_DKU2PHONET) 144 # include "protocol/nokia/phonet.h" 145 #endif 146 #if defined(GSM_ENABLE_AT) || defined(GSM_ENABLE_BLUEAT) || defined(GSM_ENABLE_IRDAAT) || defined(GSM_ENABLE_DKU2AT) 147 # include "protocol/at/at.h" 148 #endif 149 #ifdef GSM_ENABLE_ALCABUS 150 # include "protocol/alcatel/alcabus.h" 151 #endif 152 #if defined(GSM_ENABLE_IRDAOBEX) || defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_ATOBEX) 153 # include "protocol/obex/obex.h" 154 #endif 155 #if defined(GSM_ENABLE_BLUEGNAPBUS) || defined(GSM_ENABLE_IRDAGNAPBUS) 156 # include "protocol/symbian/gnapbus.h" 157 #endif 158 #if defined(GSM_ENABLE_S60) 159 # include "protocol/s60/s60.h" 160 #endif 161 162 #define GSM_ENABLE_SERIALDEVICE 163 #ifndef GSM_USED_SERIALDEVICE 164 # undef GSM_ENABLE_SERIALDEVICE 165 #endif 166 #ifdef LIBUSB_FOUND 167 #define GSM_ENABLE_USBDEVICE 168 #endif 169 #ifndef GSM_USED_USBDEVICE 170 # undef GSM_ENABLE_USBDEVICE 171 #endif 172 #define GSM_ENABLE_IRDADEVICE 173 #ifndef GSM_USED_IRDADEVICE 174 # undef GSM_ENABLE_IRDADEVICE 175 #endif 176 #if defined(BLUEZ_FOUND) || defined(BSD_BLUE_FOUND) || defined(OSX_BLUE_FOUND) || defined(WIN32) 177 # define GSM_ENABLE_BLUETOOTHDEVICE 178 #endif 179 #ifndef GSM_USED_BLUETOOTHDEVICE 180 # undef GSM_ENABLE_BLUETOOTHDEVICE 181 #endif 182 183 #ifdef DJGPP 184 # undef GSM_ENABLE_IRDADEVICE 185 # undef GSM_ENABLE_IRDAPHONET 186 # undef GSM_ENABLE_IRDAOBEX 187 # undef GSM_ENABLE_IRDAAT 188 # undef GSM_ENABLE_IRDAGNAPBUS 189 # undef GSM_ENABLE_DKU2AT 190 # undef GSM_ENABLE_FBUS2IRDA 191 # undef GSM_ENABLE_BLUETOOTHDEVICE 192 # undef GSM_ENABLE_BLUEPHONET 193 # undef GSM_ENABLE_BLUEOBEX 194 # undef GSM_ENABLE_BLUEAT 195 # undef GSM_ENABLE_BLUEFBUS2 196 # undef GSM_ENABLE_BLUEGNAPBUS 197 # undef GSM_ENABLE_PHONETBLUE 198 # undef GSM_ENABLE_FBUS2BLUE 199 #endif 200 201 #ifdef GSM_ENABLE_SERIALDEVICE 202 # include "device/serial/ser_w32.h" 203 # include "device/serial/ser_unx.h" 204 # include "device/serial/ser_djg.h" 205 #endif 206 #ifdef GSM_ENABLE_USBDEVICE 207 # include "device/usb/usb.h" 208 #endif 209 #ifdef GSM_ENABLE_IRDADEVICE 210 # include "device/irda/irda.h" 211 #endif 212 #ifdef GSM_ENABLE_BLUETOOTHDEVICE 213 # include "device/bluetooth/bluetooth.h" 214 #endif 215 #ifndef WIN32 216 # include "device/proxy/proxy.h" 217 #endif 218 219 #include "debug.h" 220 #include "gsmreply.h" 221 222 typedef struct EventBinding_ EventBinding; 223 224 /** 225 * Generic event handler. 226 */ 227 typedef void (*EventHandler)(GSM_StateMachine * s, void *event_data, 228 void *user_data); 229 230 /** 231 * Customization point for any needed setup before an event handler is called, 232 * if anything other than ERR_NONE is returned the event handler won't be called. 233 */ 234 typedef GSM_Error (*BeforeDeferredEvent)(GSM_StateMachine *s); 235 /** 236 * Customization point for any needed cleanup after an event handler is called 237 * or cancelled. 238 */ 239 typedef void (*AfterDeferredEvent)(GSM_StateMachine *s, EventBinding *binding); 240 241 /** 242 * Identifies the event types. 243 */ 244 typedef enum { 245 GSM_EV_UNSET = 0, 246 GSM_EV_CALL = 0x00000001, 247 GSM_EV_ALL = 0xFFFFFFFF 248 } EventType; 249 250 /** 251 * An event binding associates event data with a handler. 252 */ 253 typedef struct EventBinding_ { 254 EventType type; 255 EventHandler handler; 256 BeforeDeferredEvent before_event; 257 AfterDeferredEvent after_event; 258 gboolean event_cancelled; 259 union { 260 GSM_Call call; 261 } event_data; 262 void *user_data; 263 } EventBinding; 264 265 /** 266 * Queue of events awaiting processing. 267 */ 268 typedef struct { 269 int head; 270 int tail; 271 int entries; 272 EventBinding event_bindings[MAX_DEFERRED_EVENTS]; 273 } DeferredEventQueue; 274 275 /** 276 * Defers running an incoming call handler if an existing command is already 277 * executing, otherwise the handler is run immediately. 278 */ 279 GSM_Error GSM_DeferIncomingCallEvent(GSM_StateMachine *s, GSM_Call *call, 280 BeforeDeferredEvent before_event); 281 282 /** 283 * Cancels running any deferred event handlers matching the given event_types mask. 284 */ 285 void GSM_CancelEventsOfType(GSM_StateMachine *s, unsigned event_types); 286 287 /* ------------------------- Device layer ---------------------------------- */ 288 289 /** 290 * Device functions, each device has to provide these. 291 */ 292 typedef struct { 293 /** 294 * Opens device. 295 */ 296 GSM_Error (*OpenDevice) (GSM_StateMachine *s); 297 /** 298 * Closes device. 299 */ 300 GSM_Error (*CloseDevice) (GSM_StateMachine *s); 301 /** 302 * Sets parity for device. 303 */ 304 GSM_Error (*DeviceSetParity) (GSM_StateMachine *s, gboolean parity); 305 /** 306 * Sets dtr (data to read) and rts (ready to send) flags. 307 */ 308 GSM_Error (*DeviceSetDtrRts) (GSM_StateMachine *s, gboolean dtr, gboolean rts); 309 /** 310 * Sets device speed. 311 */ 312 GSM_Error (*DeviceSetSpeed) (GSM_StateMachine *s, int speed); 313 /** 314 * Attempts to read nbytes from device. 315 */ 316 ssize_t (*ReadDevice) (GSM_StateMachine *s, void *buf, size_t nbytes); 317 /** 318 * Attempts to read nbytes from device. 319 */ 320 ssize_t (*WriteDevice) (GSM_StateMachine *s, const void *buf, size_t nbytes); 321 } GSM_Device_Functions; 322 323 #ifdef GSM_ENABLE_SERIALDEVICE 324 /** 325 * Serial device functions. 326 */ 327 extern GSM_Device_Functions SerialDevice; 328 #endif 329 #ifdef GSM_ENABLE_IRDADEVICE 330 /** 331 * IrDA device functions. 332 */ 333 extern GSM_Device_Functions IrdaDevice; 334 #endif 335 #ifdef GSM_ENABLE_BLUETOOTHDEVICE 336 /** 337 * Bluetooth device functions. 338 */ 339 extern GSM_Device_Functions BlueToothDevice; 340 #endif 341 #ifdef GSM_ENABLE_USBDEVICE 342 /** 343 * Serial device functions. 344 */ 345 extern GSM_Device_Functions FBUSUSBDevice; 346 #endif 347 #ifndef WIN32 348 /** 349 * Proxy device functions. 350 */ 351 extern GSM_Device_Functions ProxyDevice; 352 #endif 353 354 /** 355 * Structure containing device specific data and pointer to device functions - 356 * @ref GSM_Device_Functions. The data are in a union, so you can use only 357 * one device at one time. 358 */ 359 typedef struct { 360 union { 361 /** 362 * Fake memeber to ensure union has always at least one member. 363 */ 364 char fake; 365 #ifdef GSM_ENABLE_SERIALDEVICE 366 /** 367 * Data for serial port device. 368 */ 369 GSM_Device_SerialData Serial; 370 #endif 371 #ifdef GSM_ENABLE_IRDADEVICE 372 /** 373 * Data for IrDA port device. 374 */ 375 GSM_Device_IrdaData Irda; 376 #endif 377 #ifdef GSM_ENABLE_BLUETOOTHDEVICE 378 /** 379 * Data for Bluetooth port device. 380 */ 381 GSM_Device_BlueToothData BlueTooth; 382 #endif 383 #ifdef GSM_ENABLE_USBDEVICE 384 /** 385 * Data for libusb-1.0 backend. 386 */ 387 GSM_Device_USBData USB; 388 #endif 389 #ifndef WIN32 390 /** 391 * Data for shell proxy. 392 */ 393 GSM_Device_ProxyData Proxy; 394 #endif 395 } Data; 396 /** 397 * Functions for currently used device. 398 */ 399 GSM_Device_Functions *Functions; 400 } GSM_Device; 401 402 /* ---------------------- Protocol layer ----------------------------------- */ 403 404 /** 405 * Protocol functions, each protocol has to implement these. 406 */ 407 typedef struct { 408 /** 409 * Writes message to device. 410 */ 411 GSM_Error (*WriteMessage) (GSM_StateMachine *s, unsigned const char *buffer, 412 size_t length, int type); 413 /** 414 * This one is called when character is received from device. 415 */ 416 GSM_Error (*StateMachine) (GSM_StateMachine *s, unsigned char rx_char); 417 /** 418 * Protocol initialisation. 419 */ 420 GSM_Error (*Initialise) (GSM_StateMachine *s); 421 /** 422 * Protocol termination. 423 */ 424 GSM_Error (*Terminate) (GSM_StateMachine *s); 425 } GSM_Protocol_Functions; 426 427 #ifdef GSM_ENABLE_MBUS2 428 extern GSM_Protocol_Functions MBUS2Protocol; 429 #endif 430 #if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_DKU5FBUS2) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2PL2303) 431 extern GSM_Protocol_Functions FBUS2Protocol; 432 #endif 433 #if defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_IRDAPHONET) || defined(GSM_ENABLE_BLUEPHONET) || defined(GSM_ENABLE_DKU2PHONET) 434 extern GSM_Protocol_Functions PHONETProtocol; 435 #endif 436 #if defined(GSM_ENABLE_AT) || defined(GSM_ENABLE_BLUEAT) || defined(GSM_ENABLE_IRDAAT) || defined(GSM_ENABLE_DKU2AT) 437 extern GSM_Protocol_Functions ATProtocol; 438 #endif 439 #ifdef GSM_ENABLE_ALCABUS 440 extern GSM_Protocol_Functions ALCABUSProtocol; 441 #endif 442 #if defined(GSM_ENABLE_IRDAOBEX) || defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_ATOBEX) 443 extern GSM_Protocol_Functions OBEXProtocol; 444 #endif 445 #if defined(GSM_ENABLE_BLUEGNAPBUS) || defined(GSM_ENABLE_IRDAGNAPBUS) 446 extern GSM_Protocol_Functions GNAPBUSProtocol; 447 #endif 448 #if defined(GSM_ENABLE_S60) 449 extern GSM_Protocol_Functions S60Protocol; 450 #endif 451 452 /** 453 * Structure containing protocol specific data and pointer to protocol 454 * functions - @ref GSM_Protocol_Functions. The data are in a structure, so 455 * you may use more protocols at once and switch between them. 456 */ 457 typedef struct { 458 struct { 459 char fake; 460 #ifdef GSM_ENABLE_MBUS2 461 GSM_Protocol_MBUS2Data MBUS2; 462 #endif 463 #if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_DKU5FBUS2) || defined(GSM_ENABLE_FBUS2PL2303) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) 464 GSM_Protocol_FBUS2Data FBUS2; 465 #endif 466 #if defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_IRDAPHONET) || defined(GSM_ENABLE_BLUEPHONET) || defined(GSM_ENABLE_DKU2PHONET) 467 GSM_Protocol_PHONETData PHONET; 468 #endif 469 #if defined(GSM_ENABLE_AT) || defined(GSM_ENABLE_BLUEAT) || defined(GSM_ENABLE_IRDAAT) || defined(GSM_ENABLE_DKU2AT) 470 GSM_Protocol_ATData AT; 471 #endif 472 #ifdef GSM_ENABLE_ALCABUS 473 GSM_Protocol_ALCABUSData ALCABUS; 474 #endif 475 #if defined(GSM_ENABLE_IRDAOBEX) || defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_ATOBEX) 476 GSM_Protocol_OBEXData OBEX; 477 #endif 478 #if defined(GSM_ENABLE_BLUEGNAPBUS) || defined(GSM_ENABLE_IRDAGNAPBUS) 479 GSM_Protocol_GNAPBUSData GNAPBUS; 480 #endif 481 #if defined(GSM_ENABLE_S60) 482 GSM_Protocol_S60Data S60; 483 #endif 484 } Data; 485 /** 486 * Functions for currently used protocol layer. 487 */ 488 GSM_Protocol_Functions *Functions; 489 } GSM_Protocol; 490 491 /* -------------------------- Phone layer ---------------------------------- */ 492 493 494 /** 495 * Phone related data are stored here. 496 */ 497 typedef struct { 498 /** 499 * Phone IMEI (or serial number). 500 */ 501 char IMEI[GSM_MAX_IMEI_LENGTH + 1]; 502 /** 503 * Phone manufacturer as reported by phone. 504 */ 505 char Manufacturer[GSM_MAX_MANUFACTURER_LENGTH + 1]; 506 /** 507 * Phone model as reported by phone. 508 */ 509 char Model[GSM_MAX_MODEL_LENGTH + 1]; 510 /** 511 * Model information, pointer to static @ref allmodels array. 512 */ 513 GSM_PhoneModel *ModelInfo; 514 /** 515 * Phone version as reported by phone. It doesn't have to be numerical 516 * at all. 517 */ 518 char Version[GSM_MAX_VERSION_LENGTH + 1]; 519 /** 520 * Phone version date, might be empty for some models. 521 */ 522 char VerDate[GSM_MAX_VERSION_DATE_LENGTH + 1]; 523 /** 524 * Phone version as number, if applicable. 525 */ 526 double VerNum; 527 /** 528 * Cache for hardware version used by some modules. 529 */ 530 char HardwareCache[50]; 531 /** 532 * Cache for product code version used by some modules. 533 */ 534 char ProductCodeCache[50]; 535 536 /** 537 * Counter used for disabling startup info on phone, see 538 * @ref GSM_Phone_Functions::ShowStartInfo . After this is 0, the startup info is hidden. 539 */ 540 int StartInfoCounter; 541 542 /** 543 * Pointer to structure used internally by phone drivers. 544 */ 545 GSM_GPRSAccessPoint *GPRSPoint; 546 /** 547 * Pointer to structure used internally by phone drivers. 548 */ 549 GSM_SpeedDial *SpeedDial; 550 /** 551 * Pointer to structure used internally by phone drivers. 552 */ 553 GSM_DateTime *DateTime; 554 /** 555 * Pointer to structure used internally by phone drivers. 556 */ 557 GSM_Alarm *Alarm; 558 /** 559 * Pointer to structure used internally by phone drivers. 560 */ 561 GSM_MemoryEntry *Memory; 562 /** 563 * Pointer to structure used internally by phone drivers. 564 */ 565 GSM_MemoryStatus *MemoryStatus; 566 /** 567 * Pointer to structure used internally by phone drivers. 568 */ 569 GSM_SMSC *SMSC; 570 /** 571 * Pointer to structure used internally by phone drivers. 572 */ 573 GSM_MultiSMSMessage *GetSMSMessage; 574 /** 575 * Pointer to structure used internally by phone drivers. 576 */ 577 GSM_SMSMessage *SaveSMSMessage; 578 /** 579 * Pointer to structure used internally by phone drivers. 580 */ 581 GSM_SMSMemoryStatus *SMSStatus; 582 /** 583 * Pointer to structure used internally by phone drivers. 584 */ 585 GSM_SMSFolders *SMSFolders; 586 /** 587 * Used internally by phone drivers. 588 */ 589 size_t *VoiceRecord; 590 /** 591 * Used internally by phone drivers. 592 */ 593 int CallID; 594 /** 595 * Pointer to structure used internally by phone drivers. 596 */ 597 GSM_SignalQuality *SignalQuality; 598 /** 599 * Pointer to structure used internally by phone drivers. 600 */ 601 GSM_BatteryCharge *BatteryCharge; 602 /** 603 * Pointer to structure used internally by phone drivers. 604 */ 605 GSM_NetworkInfo *NetworkInfo; 606 /** 607 * Pointer to structure used internally by phone drivers. 608 */ 609 GSM_Ringtone *Ringtone; 610 /** 611 * Pointer to structure used internally by phone drivers. 612 */ 613 GSM_CalendarEntry *Cal; 614 /** 615 * Calendar status. 616 */ 617 GSM_CalendarStatus *CalStatus; 618 /** 619 * Todo status. 620 */ 621 GSM_ToDoStatus *ToDoStatus; 622 /** 623 * Used internally by phone drivers. 624 */ 625 unsigned char *SecurityCode; 626 /** 627 * Pointer to structure used internally by phone drivers. 628 */ 629 GSM_WAPBookmark *WAPBookmark; 630 /** 631 * Pointer to structure used internally by phone drivers. 632 */ 633 GSM_MultiWAPSettings *WAPSettings; 634 /** 635 * Pointer to structure used internally by phone drivers. 636 */ 637 GSM_Bitmap *Bitmap; 638 /** 639 * Used internally by phone drivers. 640 */ 641 unsigned char *Netmonitor; 642 /** 643 * Pointer to call diversion structure used internally by phone drivers. 644 */ 645 GSM_MultiCallDivert *Divert; 646 /** 647 * Pointer to todo structure used internally by phone drivers. 648 */ 649 GSM_ToDoEntry *ToDo; 650 /** 651 * Pointer to note structure used internally by phone drivers. 652 */ 653 GSM_NoteEntry *Note; 654 /** 655 * Pointer to picture structure used internally by phone drivers. 656 */ 657 GSM_BinaryPicture *Picture; 658 /** 659 * Used internally by phone drivers. 660 */ 661 gboolean PressKey; 662 /** 663 * Pointer to structure used internally by phone drivers. 664 */ 665 GSM_SecurityCodeType *SecurityStatus; 666 /** 667 * Pointer to structure used internally by phone drivers. 668 */ 669 GSM_Profile *Profile; 670 /** 671 * Pointer to structure used internally by phone drivers. 672 */ 673 GSM_AllRingtonesInfo *RingtonesInfo; 674 /** 675 * Pointer to structure used internally by phone drivers. 676 */ 677 GSM_DisplayFeatures *DisplayFeatures; 678 /** 679 * Pointer to structure used internally by phone drivers. 680 */ 681 GSM_FMStation *FMStation; 682 /** 683 * Pointer to structure used internally by phone drivers. 684 */ 685 GSM_Locale *Locale; 686 /** 687 * Pointer to structure used internally by phone drivers. 688 */ 689 GSM_CalendarSettings *CalendarSettings; 690 /** 691 * Used internally by phone drivers. 692 */ 693 unsigned char *PhoneString; 694 int FileHandle; 695 /** 696 * Used internally by phone drivers. 697 */ 698 int StartPhoneString; 699 /** 700 * Pointer to structure used internally by phone drivers. 701 */ 702 GSM_File *FileInfo; 703 /** 704 * Pointer to structure used internally by phone drivers. 705 */ 706 GSM_File *File; 707 /** 708 * Pointer to structure used internally by phone drivers. 709 */ 710 GSM_FileSystemStatus *FileSystemStatus; 711 /** 712 * Pointer to structure used internally by phone drivers. 713 */ 714 GSM_ChatSettings *ChatSettings; 715 /** 716 * Pointer to structure used internally by phone drivers. 717 */ 718 GSM_SyncMLSettings *SyncMLSettings; 719 720 /** 721 * Should phone notify about incoming calls? 722 */ 723 gboolean EnableIncomingCall; 724 /** 725 * Should phone notify about incoming SMSes? 726 */ 727 gboolean EnableIncomingSMS; 728 /** 729 * Should phone notify about incoming CBs? 730 */ 731 gboolean EnableIncomingCB; 732 /** 733 * Should phone notify about incoming USSDs? 734 */ 735 gboolean EnableIncomingUSSD; 736 737 /** 738 * Last message received from phone. 739 */ 740 GSM_Protocol_Message *RequestMsg; 741 /** 742 * Last message sent by Gammu. 743 */ 744 GSM_Protocol_Message *SentMsg; 745 /** 746 * What operation is being performed now, see @ref GSM_Phone_RequestID 747 * for possible values. 748 */ 749 GSM_Phone_RequestID RequestID; 750 /** 751 * Error returned by function in phone module. 752 */ 753 GSM_Error DispatchError; 754 /** 755 * Queue of events awaiting processing. 756 */ 757 DeferredEventQueue DeferredEvents; 758 759 /** 760 * Structure with private phone modules data. 761 */ 762 struct { 763 #ifdef GSM_ENABLE_NOKIA3320 764 GSM_Phone_N3320Data N3320; 765 #endif 766 #ifdef GSM_ENABLE_NOKIA3650 767 GSM_Phone_N3650Data N3650; 768 #endif 769 #ifdef GSM_ENABLE_NOKIA650 770 GSM_Phone_N650Data N650; 771 #endif 772 #ifdef GSM_ENABLE_NOKIA6110 773 GSM_Phone_N6110Data N6110; 774 #endif 775 #ifdef GSM_ENABLE_NOKIA6510 776 GSM_Phone_N6510Data N6510; 777 #endif 778 #ifdef GSM_ENABLE_NOKIA7110 779 GSM_Phone_N7110Data N7110; 780 #endif 781 #ifdef GSM_ENABLE_ATGEN 782 GSM_Phone_ATGENData ATGEN; 783 #endif 784 #ifdef GSM_ENABLE_ALCATEL 785 GSM_Phone_ALCATELData ALCATEL; 786 #endif 787 #ifdef GSM_ENABLE_ATOBEX 788 GSM_Phone_ATOBEXData ATOBEX; 789 #endif 790 #ifdef GSM_ENABLE_OBEXGEN 791 GSM_Phone_OBEXGENData OBEXGEN; 792 #endif 793 #ifdef GSM_ENABLE_GNAPGEN 794 GSM_Phone_GNAPGENData GNAPGEN; 795 #endif 796 #ifdef GSM_ENABLE_S60 797 GSM_Phone_S60Data S60; 798 #endif 799 GSM_Phone_DUMMYData DUMMY; 800 } Priv; 801 } GSM_Phone_Data; 802 803 /** 804 * Structure defining phone functions. 805 */ 806 typedef struct { 807 /** 808 * Names of supported models separated by |. Must contain at least one 809 * name. 810 */ 811 const char *models; 812 /** 813 * Array of reply functions for the phone, see 814 * @ref GSM_Reply_Function for details about it. 815 */ 816 GSM_Reply_Function *ReplyFunctions; 817 /** 818 * Installs required applets to the phone. 819 */ 820 GSM_Error (*Install) (GSM_StateMachine *s, const char *ExtraPath, gboolean Minimal); 821 /** 822 * Initializes phone. 823 */ 824 GSM_Error (*Initialise) (GSM_StateMachine *s); 825 /** 826 * Terminates phone communication. 827 */ 828 GSM_Error (*Terminate) (GSM_StateMachine *s); 829 /** 830 * Dispatches messages from phone, at the end it should call 831 * @ref GSM_DispatchMessage. 832 */ 833 GSM_Error (*DispatchMessage) (GSM_StateMachine *s); 834 /** 835 * Enables showing information on phone display. 836 */ 837 GSM_Error (*ShowStartInfo) (GSM_StateMachine *s, gboolean enable); 838 /** 839 * Reads manufacturer from phone. 840 */ 841 GSM_Error (*GetManufacturer) (GSM_StateMachine *s); 842 /** 843 * Reads model from phone. 844 */ 845 GSM_Error (*GetModel) (GSM_StateMachine *s); 846 /** 847 * Reads firmware information from phone. 848 */ 849 GSM_Error (*GetFirmware) (GSM_StateMachine *s); 850 /** 851 * Reads IMEI/serial number from phone. 852 */ 853 GSM_Error (*GetIMEI) (GSM_StateMachine *s); 854 /** 855 * Gets date and time from phone. 856 */ 857 GSM_Error (*GetOriginalIMEI) (GSM_StateMachine *s, char *value); 858 /** 859 * Gets month when device was manufactured. 860 */ 861 GSM_Error (*GetManufactureMonth)(GSM_StateMachine *s, char *value); 862 /** 863 * Gets product code of device. 864 */ 865 GSM_Error (*GetProductCode) (GSM_StateMachine *s, char *value); 866 /** 867 * Gets hardware information about device. 868 */ 869 GSM_Error (*GetHardware) (GSM_StateMachine *s, char *value); 870 /** 871 * Gets PPM (Post Programmable Memory) info from phone 872 * (in other words for Nokia get, which language pack is in phone) 873 */ 874 GSM_Error (*GetPPM) (GSM_StateMachine *s, char *value); 875 /** 876 * Gets SIM IMSI from phone. 877 */ 878 GSM_Error (*GetSIMIMSI) (GSM_StateMachine *s, char *IMSI); 879 /** 880 * Reads date and time from phone. 881 */ 882 GSM_Error (*GetDateTime) (GSM_StateMachine *s, GSM_DateTime *date_time); 883 /** 884 * Sets date and time in phone. 885 */ 886 GSM_Error (*SetDateTime) (GSM_StateMachine *s, GSM_DateTime *date_time); 887 /** 888 * Reads alarm set in phone. 889 */ 890 GSM_Error (*GetAlarm) (GSM_StateMachine *s, GSM_Alarm *Alarm); 891 /** 892 * Sets alarm in phone. 893 */ 894 GSM_Error (*SetAlarm) (GSM_StateMachine *s, GSM_Alarm *Alarm); 895 /** 896 * Gets locale from phone. 897 */ 898 GSM_Error (*GetLocale) (GSM_StateMachine *s, GSM_Locale *locale); 899 /** 900 * Sets locale of phone. 901 */ 902 GSM_Error (*SetLocale) (GSM_StateMachine *s, GSM_Locale *locale); 903 /** 904 * Emulates key press or key release. 905 */ 906 GSM_Error (*PressKey) (GSM_StateMachine *s, GSM_KeyCode Key, gboolean Press); 907 /** 908 * Performs phone reset. 909 */ 910 GSM_Error (*Reset) (GSM_StateMachine *s, gboolean hard); 911 /** 912 * Resets phone settings. 913 */ 914 GSM_Error (*ResetPhoneSettings) (GSM_StateMachine *s, GSM_ResetSettingsType Type); 915 /** 916 * Enters security code (PIN, PUK,...) . 917 */ 918 GSM_Error (*EnterSecurityCode) (GSM_StateMachine *s, GSM_SecurityCode *Code); 919 /** 920 * Queries whether some security code needs to be entered./ 921 */ 922 GSM_Error (*GetSecurityStatus) (GSM_StateMachine *s, GSM_SecurityCodeType *Status); 923 /** 924 * Acquired display status. 925 */ 926 GSM_Error (*GetDisplayStatus) (GSM_StateMachine *s, GSM_DisplayFeatures *features); 927 /** 928 * Enables network auto login. 929 */ 930 GSM_Error (*SetAutoNetworkLogin)(GSM_StateMachine *s); 931 /** 932 * Gets information about batery charge and phone charging state. 933 */ 934 GSM_Error (*GetBatteryCharge) (GSM_StateMachine *s, GSM_BatteryCharge *bat); 935 /** 936 * Reads signal quality (strength and error rate). 937 */ 938 GSM_Error (*GetSignalQuality) (GSM_StateMachine *s, GSM_SignalQuality *sig); 939 /** 940 * Gets network information. 941 */ 942 GSM_Error (*GetNetworkInfo) (GSM_StateMachine *s, GSM_NetworkInfo *netinfo); 943 /** 944 * Reads category from phone. 945 */ 946 GSM_Error (*GetCategory) (GSM_StateMachine *s, GSM_Category *Category); 947 /** 948 * Adds category to phone. 949 */ 950 GSM_Error (*AddCategory) (GSM_StateMachine *s, GSM_Category *Category); 951 /** 952 * Reads category status (number of used entries) from phone. 953 */ 954 GSM_Error (*GetCategoryStatus) (GSM_StateMachine *s, GSM_CategoryStatus *Status); 955 /** 956 * Gets memory (phonebooks or calls) status (eg. number of used and 957 * free entries). 958 */ 959 GSM_Error (*GetMemoryStatus) (GSM_StateMachine *s, GSM_MemoryStatus *status); 960 /** 961 * Reads entry from memory (phonebooks or calls). Which entry should 962 * be read is defined in entry. 963 */ 964 GSM_Error (*GetMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry); 965 /** 966 * Reads entry from memory (phonebooks or calls). Which entry should 967 * be read is defined in entry. This can be easily used for reading all entries. 968 */ 969 GSM_Error (*GetNextMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry, gboolean start); 970 /** 971 * Sets memory (phonebooks or calls) entry. 972 */ 973 GSM_Error (*SetMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry); 974 /** 975 * Deletes memory (phonebooks or calls) entry. 976 */ 977 GSM_Error (*AddMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry); 978 /** 979 * Deletes memory (phonebooks or calls) entry. 980 */ 981 GSM_Error (*DeleteMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry); 982 /** 983 * Deletes all memory (phonebooks or calls) entries of specified type. 984 */ 985 GSM_Error (*DeleteAllMemory) (GSM_StateMachine *s, GSM_MemoryType MemoryType); 986 /** 987 * Gets speed dial. 988 */ 989 GSM_Error (*GetSpeedDial) (GSM_StateMachine *s, GSM_SpeedDial *Speed); 990 /** 991 * Sets speed dial. 992 */ 993 GSM_Error (*SetSpeedDial) (GSM_StateMachine *s, GSM_SpeedDial *Speed); 994 /** 995 * Gets SMS Service Center number and SMS settings. 996 */ 997 GSM_Error (*GetSMSC) (GSM_StateMachine *s, GSM_SMSC *smsc); 998 /** 999 * Sets SMS Service Center number and SMS settings. 1000 */ 1001 GSM_Error (*SetSMSC) (GSM_StateMachine *s, GSM_SMSC *smsc); 1002 /** 1003 * Gets information about SMS memory (read/unread/size of memory for 1004 * both SIM and phone). 1005 */ 1006 GSM_Error (*GetSMSStatus) (GSM_StateMachine *s, GSM_SMSMemoryStatus *status); 1007 /** 1008 * Reads SMS message. 1009 */ 1010 GSM_Error (*GetSMS) (GSM_StateMachine *s, GSM_MultiSMSMessage *sms); 1011 /** 1012 * Reads next (or first if start set) SMS message. This might be 1013 * faster for some phones than using @ref GetSMS for each message. 1014 */ 1015 GSM_Error (*GetNextSMS) (GSM_StateMachine *s, GSM_MultiSMSMessage *sms, gboolean start); 1016 /** 1017 * Sets SMS. 1018 */ 1019 GSM_Error (*SetSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms); 1020 /** 1021 * Adds SMS to specified folder. 1022 */ 1023 GSM_Error (*AddSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms); 1024 /** 1025 * Deletes SMS. 1026 */ 1027 GSM_Error (*DeleteSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms); 1028 /** 1029 * Sends SMS. 1030 */ 1031 GSM_Error (*SendSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms); 1032 /** 1033 * Sends SMS already saved in phone. 1034 */ 1035 GSM_Error (*SendSavedSMS) (GSM_StateMachine *s, int Folder, int Location); 1036 /** 1037 * Configures fast SMS sending. 1038 */ 1039 GSM_Error (*SetFastSMSSending) (GSM_StateMachine *s, gboolean enable); 1040 /** 1041 * Enable/disable notification on incoming SMS. 1042 */ 1043 GSM_Error (*SetIncomingSMS) (GSM_StateMachine *s, gboolean enable); 1044 /** 1045 * Gets network information from phone. 1046 */ 1047 GSM_Error (*SetIncomingCB) (GSM_StateMachine *s, gboolean enable); 1048 /** 1049 * Returns SMS folders information. 1050 */ 1051 GSM_Error (*GetSMSFolders) (GSM_StateMachine *s, GSM_SMSFolders *folders); 1052 /** 1053 * Creates SMS folder. 1054 */ 1055 GSM_Error (*AddSMSFolder) (GSM_StateMachine *s, unsigned char *name); 1056 /** 1057 * Deletes SMS folder. 1058 */ 1059 GSM_Error (*DeleteSMSFolder) (GSM_StateMachine *s, int ID); 1060 /** 1061 * Dials number and starts voice call. 1062 */ 1063 GSM_Error (*DialVoice) (GSM_StateMachine *s, char *Number, GSM_CallShowNumber ShowNumber); 1064 /** 1065 * Dials service number (usually for USSD). 1066 */ 1067 GSM_Error (*DialService) (GSM_StateMachine *s, char *Number); 1068 /** 1069 * Accept current incoming call. 1070 */ 1071 GSM_Error (*AnswerCall) (GSM_StateMachine *s, int ID, gboolean all); 1072 /** 1073 * Deny current incoming call. 1074 */ 1075 GSM_Error (*CancelCall) (GSM_StateMachine *s, int ID, gboolean all); 1076 /** 1077 * Holds call. 1078 */ 1079 GSM_Error (*HoldCall) (GSM_StateMachine *s, int ID); 1080 /** 1081 * Unholds call. 1082 */ 1083 GSM_Error (*UnholdCall) (GSM_StateMachine *s, int ID); 1084 /** 1085 * Initiates conference call. 1086 */ 1087 GSM_Error (*ConferenceCall) (GSM_StateMachine *s, int ID); 1088 /** 1089 * Splits call. 1090 */ 1091 GSM_Error (*SplitCall) (GSM_StateMachine *s, int ID); 1092 /** 1093 * Transfers call. 1094 */ 1095 GSM_Error (*TransferCall) (GSM_StateMachine *s, int ID, gboolean next); 1096 /** 1097 * Switches call. 1098 */ 1099 GSM_Error (*SwitchCall) (GSM_StateMachine *s, int ID, gboolean next); 1100 /** 1101 * Gets call diverts. 1102 */ 1103 GSM_Error (*GetCallDivert) (GSM_StateMachine *s, GSM_CallDivert *request, GSM_MultiCallDivert *result); 1104 /** 1105 * Sets call diverts. 1106 */ 1107 GSM_Error (*SetCallDivert) (GSM_StateMachine *s, GSM_CallDivert *divert); 1108 /** 1109 * Cancels all diverts. 1110 */ 1111 GSM_Error (*CancelAllDiverts) (GSM_StateMachine *s); 1112 /** 1113 * Activates/deactivates noticing about incoming calls. 1114 */ 1115 GSM_Error (*SetIncomingCall) (GSM_StateMachine *s, gboolean enable); 1116 /** 1117 * Activates/deactivates noticing about incoming USSDs (UnStructured Supplementary Services). 1118 */ 1119 GSM_Error (*SetIncomingUSSD) (GSM_StateMachine *s, gboolean enable); 1120 /** 1121 * Sends DTMF (Dual Tone Multi Frequency) tone. 1122 */ 1123 GSM_Error (*SendDTMF) (GSM_StateMachine *s, char *sequence); 1124 /** 1125 * Gets ringtone from phone. 1126 */ 1127 GSM_Error (*GetRingtone) (GSM_StateMachine *s, GSM_Ringtone *Ringtone, gboolean PhoneRingtone); 1128 /** 1129 * Sets ringtone in phone. 1130 */ 1131 GSM_Error (*SetRingtone) (GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength); 1132 /** 1133 * Acquires ringtone informaiton. 1134 */ 1135 GSM_Error (*GetRingtonesInfo) (GSM_StateMachine *s, GSM_AllRingtonesInfo *Info); 1136 /** 1137 * Deletes user defined ringtones from phone. 1138 */ 1139 GSM_Error (*DeleteUserRingtones)(GSM_StateMachine *s); 1140 /** 1141 * Plays tone. 1142 */ 1143 GSM_Error (*PlayTone) (GSM_StateMachine *s, int Herz, unsigned char Volume, gboolean start); 1144 /** 1145 * Reads WAP bookmark. 1146 */ 1147 GSM_Error (*GetWAPBookmark) (GSM_StateMachine *s, GSM_WAPBookmark *bookmark); 1148 /** 1149 * Sets WAP bookmark. 1150 */ 1151 GSM_Error (*SetWAPBookmark) (GSM_StateMachine *s, GSM_WAPBookmark *bookmark); 1152 /** 1153 * Deletes WAP bookmark. 1154 */ 1155 GSM_Error (*DeleteWAPBookmark) (GSM_StateMachine *s, GSM_WAPBookmark *bookmark); 1156 /** 1157 * Acquires WAP settings. 1158 */ 1159 GSM_Error (*GetWAPSettings) (GSM_StateMachine *s, GSM_MultiWAPSettings *settings); 1160 /** 1161 * Changes WAP settings. 1162 */ 1163 GSM_Error (*SetWAPSettings) (GSM_StateMachine *s, GSM_MultiWAPSettings *settings); 1164 /** 1165 * Acquires SyncML settings. 1166 */ 1167 GSM_Error (*GetSyncMLSettings) (GSM_StateMachine *s, GSM_SyncMLSettings *settings); 1168 /** 1169 * Changes SyncML settings. 1170 */ 1171 GSM_Error (*SetSyncMLSettings) (GSM_StateMachine *s, GSM_SyncMLSettings *settings); 1172 /** 1173 * Acquires chat/presence settings. 1174 */ 1175 GSM_Error (*GetChatSettings) (GSM_StateMachine *s, GSM_ChatSettings *settings); 1176 /** 1177 * Changes chat/presence settings. 1178 */ 1179 GSM_Error (*SetChatSettings) (GSM_StateMachine *s, GSM_ChatSettings *settings); 1180 /** 1181 * Acquires MMS settings. 1182 */ 1183 GSM_Error (*GetMMSSettings) (GSM_StateMachine *s, GSM_MultiWAPSettings *settings); 1184 /** 1185 * Changes MMS settings. 1186 */ 1187 GSM_Error (*SetMMSSettings) (GSM_StateMachine *s, GSM_MultiWAPSettings *settings); 1188 /** 1189 * Lists MMS folders. 1190 */ 1191 GSM_Error (*GetMMSFolders) (GSM_StateMachine *s, GSM_MMSFolders *folders); 1192 /** 1193 * Retrieves next part of MMS file information. 1194 */ 1195 GSM_Error (*GetNextMMSFileInfo) (GSM_StateMachine *s, unsigned char *FileID, int *MMSFolder, gboolean start); 1196 /** 1197 * Gets bitmap. 1198 */ 1199 GSM_Error (*GetBitmap) (GSM_StateMachine *s, GSM_Bitmap *Bitmap); 1200 /** 1201 * Sets bitmap. 1202 */ 1203 GSM_Error (*SetBitmap) (GSM_StateMachine *s, GSM_Bitmap *Bitmap); 1204 /** 1205 * Gets status of ToDos (count of used entries). 1206 */ 1207 GSM_Error (*GetToDoStatus) (GSM_StateMachine *s, GSM_ToDoStatus *status); 1208 /** 1209 * Reads ToDo from phone. 1210 */ 1211 GSM_Error (*GetToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo); 1212 /** 1213 * Reads ToDo from phone. 1214 */ 1215 GSM_Error (*GetNextToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo, gboolean start); 1216 /** 1217 * Sets ToDo in phone. 1218 */ 1219 GSM_Error (*SetToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo); 1220 /** 1221 * Adds ToDo in phone. 1222 */ 1223 GSM_Error (*AddToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo); 1224 /** 1225 * Deletes ToDo entry in phone. 1226 */ 1227 GSM_Error (*DeleteToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo); 1228 /** 1229 * Deletes all todo entries in phone. 1230 */ 1231 GSM_Error (*DeleteAllToDo) (GSM_StateMachine *s); 1232 /** 1233 * Retrieves calendar status (number of used entries). 1234 */ 1235 GSM_Error (*GetCalendarStatus) (GSM_StateMachine *s, GSM_CalendarStatus *Status); 1236 /** 1237 * Retrieves calendar entry. 1238 */ 1239 GSM_Error (*GetCalendar) (GSM_StateMachine *s, GSM_CalendarEntry *Note); 1240 /** 1241 * Retrieves calendar entry. This is useful for continuous reading of all 1242 * calendar entries. 1243 */ 1244 GSM_Error (*GetNextCalendar) (GSM_StateMachine *s, GSM_CalendarEntry *Note, gboolean start); 1245 /** 1246 * Sets calendar entry 1247 */ 1248 GSM_Error (*SetCalendar) (GSM_StateMachine *s, GSM_CalendarEntry *Note); 1249 /** 1250 * Adds calendar entry. 1251 */ 1252 GSM_Error (*AddCalendar) (GSM_StateMachine *s, GSM_CalendarEntry *Note); 1253 /** 1254 * Deletes calendar entry. 1255 */ 1256 GSM_Error (*DeleteCalendar) (GSM_StateMachine *s, GSM_CalendarEntry *Note); 1257 /** 1258 * Deletes all calendar entries. 1259 */ 1260 GSM_Error (*DeleteAllCalendar) (GSM_StateMachine *s); 1261 /** 1262 * Reads calendar settings. 1263 */ 1264 GSM_Error (*GetCalendarSettings)(GSM_StateMachine *s, GSM_CalendarSettings *settings); 1265 /** 1266 * Sets calendar settings. 1267 */ 1268 GSM_Error (*SetCalendarSettings)(GSM_StateMachine *s, GSM_CalendarSettings *settings); 1269 /** 1270 * Retrieves notes status (number of used entries). 1271 */ 1272 GSM_Error (*GetNotesStatus) (GSM_StateMachine *s, GSM_ToDoStatus *status); 1273 /** 1274 * Retrieves notes entry. 1275 */ 1276 GSM_Error (*GetNote) (GSM_StateMachine *s, GSM_NoteEntry *Note); 1277 /** 1278 * Retrieves note entry. This is useful for continuous reading of all 1279 * notes entries. 1280 */ 1281 GSM_Error (*GetNextNote) (GSM_StateMachine *s, GSM_NoteEntry *Note, gboolean start); 1282 /** 1283 * Sets note entry 1284 */ 1285 GSM_Error (*SetNote) (GSM_StateMachine *s, GSM_NoteEntry *Note); 1286 /** 1287 * Adds note entry. 1288 */ 1289 GSM_Error (*AddNote) (GSM_StateMachine *s, GSM_NoteEntry *Note); 1290 /** 1291 * Deletes note entry. 1292 */ 1293 GSM_Error (*DeleteNote) (GSM_StateMachine *s, GSM_NoteEntry *Note); 1294 /** 1295 * Deletes all notes entries. 1296 */ 1297 GSM_Error (*DeleteAllNotes) (GSM_StateMachine *s); 1298 /** 1299 * Reads profile. 1300 */ 1301 GSM_Error (*GetProfile) (GSM_StateMachine *s, GSM_Profile *Profile); 1302 /** 1303 * Updates profile. 1304 */ 1305 GSM_Error (*SetProfile) (GSM_StateMachine *s, GSM_Profile *Profile); 1306 /** 1307 * Reads FM station. 1308 */ 1309 GSM_Error (*GetFMStation) (GSM_StateMachine *s, GSM_FMStation *FMStation); 1310 /** 1311 * Sets FM station. 1312 */ 1313 GSM_Error (*SetFMStation) (GSM_StateMachine *s, GSM_FMStation *FMStation); 1314 /** 1315 * Clears defined FM stations. 1316 */ 1317 GSM_Error (*ClearFMStations) (GSM_StateMachine *s); 1318 /** 1319 * Gets next filename from filesystem. 1320 */ 1321 GSM_Error (*GetNextFileFolder) (GSM_StateMachine *s, GSM_File *File, gboolean start); 1322 /** 1323 * Gets file part from filesystem. 1324 */ 1325 GSM_Error (*GetFolderListing) (GSM_StateMachine *s, GSM_File *File, gboolean start); 1326 /** 1327 * Gets next root folder. 1328 */ 1329 GSM_Error (*GetNextRootFolder) (GSM_StateMachine *s, GSM_File *File); 1330 /** 1331 * Sets file system attributes. 1332 */ 1333 GSM_Error (*SetFileAttributes) (GSM_StateMachine *s, GSM_File *File); 1334 /** 1335 * Retrieves file part. 1336 */ 1337 GSM_Error (*GetFilePart) (GSM_StateMachine *s, GSM_File *File, int *Handle, size_t *Size); 1338 /** 1339 * Adds file part to filesystem. 1340 */ 1341 GSM_Error (*AddFilePart) (GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle); 1342 /** 1343 * Sends file to phone, it's up to phone to decide what to do with it. 1344 */ 1345 GSM_Error (*SendFilePart) (GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle); 1346 /** 1347 * Acquires filesystem status. 1348 */ 1349 GSM_Error (*GetFileSystemStatus)(GSM_StateMachine *s, GSM_FileSystemStatus *Status); 1350 /** 1351 * Deletes file from filessytem. 1352 */ 1353 GSM_Error (*DeleteFile) (GSM_StateMachine *s, unsigned char *ID); 1354 /** 1355 * Adds folder to filesystem. 1356 */ 1357 GSM_Error (*AddFolder) (GSM_StateMachine *s, GSM_File *File); 1358 /** 1359 * Deletes folder from filesystem. 1360 */ 1361 GSM_Error (*DeleteFolder) (GSM_StateMachine *s, unsigned char *ID); 1362 /** 1363 * Gets GPRS access point. 1364 */ 1365 GSM_Error (*GetGPRSAccessPoint) (GSM_StateMachine *s, GSM_GPRSAccessPoint *point); 1366 /** 1367 * Sets GPRS access point. 1368 */ 1369 GSM_Error (*SetGPRSAccessPoint) (GSM_StateMachine *s, GSM_GPRSAccessPoint *point); 1370 /** 1371 * Gets phone screenshot 1372 */ 1373 GSM_Error (*GetScreenshot) (GSM_StateMachine *s, GSM_BinaryPicture *picture); 1374 /** 1375 * Sets phone power state 1376 */ 1377 GSM_Error (*SetPower) (GSM_StateMachine *s, gboolean on); 1378 /** 1379 * Post connect hook 1380 */ 1381 GSM_Error (*PostConnect) (GSM_StateMachine *s); 1382 /** 1383 * API action hook, executed before API call 1384 */ 1385 GSM_Error (*PreAPICall)(GSM_StateMachine *s); 1386 } GSM_Phone_Functions; 1387 1388 extern GSM_Phone_Functions NAUTOPhone; 1389 #ifdef GSM_ENABLE_NOKIA3320 1390 extern GSM_Phone_Functions N3320Phone; 1391 #endif 1392 #ifdef GSM_ENABLE_NOKIA3650 1393 extern GSM_Phone_Functions N3650Phone; 1394 #endif 1395 #ifdef GSM_ENABLE_NOKIA6110 1396 extern GSM_Phone_Functions N6110Phone; 1397 #endif 1398 #ifdef GSM_ENABLE_NOKIA650 1399 extern GSM_Phone_Functions N650Phone; 1400 #endif 1401 #ifdef GSM_ENABLE_NOKIA6510 1402 extern GSM_Phone_Functions N6510Phone; 1403 #endif 1404 #ifdef GSM_ENABLE_NOKIA7110 1405 extern GSM_Phone_Functions N7110Phone; 1406 #endif 1407 #ifdef GSM_ENABLE_NOKIA9210 1408 extern GSM_Phone_Functions N9210Phone; 1409 #endif 1410 #ifdef GSM_ENABLE_ATGEN 1411 extern GSM_Phone_Functions ATGENPhone; 1412 #endif 1413 #ifdef GSM_ENABLE_ALCATEL 1414 extern GSM_Phone_Functions ALCATELPhone; 1415 #endif 1416 #ifdef GSM_ENABLE_ATOBEX 1417 extern GSM_Phone_Functions ATOBEXPhone; 1418 #endif 1419 #ifdef GSM_ENABLE_OBEXGEN 1420 extern GSM_Phone_Functions OBEXGENPhone; 1421 #endif 1422 #ifdef GSM_ENABLE_GNAPGEN 1423 extern GSM_Phone_Functions GNAPGENPhone; 1424 #endif 1425 #ifdef GSM_ENABLE_S60 1426 extern GSM_Phone_Functions S60Phone; 1427 #endif 1428 extern GSM_Phone_Functions DUMMYPhone; 1429 1430 /** 1431 * Phone functions and private data. 1432 */ 1433 typedef struct { 1434 /** 1435 * Private data for current phone driver. 1436 */ 1437 GSM_Phone_Data Data; 1438 /** 1439 * Functions for current phone driver. 1440 */ 1441 GSM_Phone_Functions *Functions; 1442 } GSM_Phone; 1443 1444 /* --------------------------- User layer ---------------------------------- */ 1445 1446 struct _GSM_User { 1447 GSM_Reply_Function *UserReplyFunctions; 1448 1449 IncomingCallCallback IncomingCall; 1450 IncomingSMSCallback IncomingSMS; 1451 IncomingCBCallback IncomingCB; 1452 IncomingUSSDCallback IncomingUSSD; 1453 SendSMSStatusCallback SendSMSStatus; 1454 void * IncomingCallUserData; 1455 void * IncomingSMSUserData; 1456 void * IncomingCBUserData; 1457 void * IncomingUSSDUserData; 1458 void * SendSMSStatusUserData; 1459 }; 1460 1461 /* --------------------------- Statemachine layer -------------------------- */ 1462 1463 1464 /** 1465 * Maximum number of concurrent configurations. 1466 */ 1467 #define MAX_CONFIG_NUM 5 1468 1469 struct _GSM_StateMachine { 1470 GSM_ConnectionType ConnectionType; /**< Type of connection as int */ 1471 /** 1472 * Skip lowlevel serial handling, cable is known to be broken. 1473 */ 1474 gboolean SkipDtrRts; 1475 /** 1476 * Do not give power supply to cable on DTR/RTS signals. 1477 */ 1478 gboolean NoPowerCable; 1479 char *LockFile; /**< Lock file name for Unix */ 1480 GSM_Debug_Info di; /**< Debug information */ 1481 gboolean opened; /**< Is connection opened ? */ 1482 GSM_Config Config[MAX_CONFIG_NUM + 1]; /**< Configuration data */ 1483 GSM_Config *CurrentConfig; /**< Config file (or Registry or...) variables */ 1484 int ConfigNum; /**< Number of actual configurations */ 1485 int ReplyNum; /**< How many times make sth. */ 1486 int Speed; /**< For some protocols used speed */ 1487 1488 /** 1489 * Flag for interrupting communication. 1490 */ 1491 volatile gboolean Abort; 1492 /** 1493 * Counter for dispatched messages. 1494 */ 1495 volatile size_t MessagesCount; 1496 1497 GSM_Device Device; /**< Device driver data and functions */ 1498 GSM_Protocol Protocol; /**< Protocol driver data and functions */ 1499 GSM_Phone Phone; /**< Phone driver data and functions */ 1500 GSM_User User; /**< User defined functions */ 1501 }; 1502 1503 /* ------------------------ Other general definitions ---------------------- */ 1504 1505 /** 1506 * Tries to register all modules to find one matching current configuration. 1507 * 1508 * \param s State machine pointer. 1509 * 1510 * \return Error code, ERR_NONE on success. 1511 */ 1512 GSM_Error GSM_RegisterAllPhoneModules (GSM_StateMachine *s); 1513 1514 GSM_Error GSM_WaitForOnce (GSM_StateMachine *s, unsigned const char *buffer, 1515 size_t length, int type, int timeout); 1516 1517 /** 1518 * Wait for reply from the phone. 1519 * 1520 * \param s State machine pointer. 1521 * \param buffer Data to write to phone. 1522 * \param length Length of data in buffer. 1523 * \param type Type of request (for protocols where it makes sense). 1524 * \param timeout How long to wait for reply. 1525 * \param request ID of request 1526 * 1527 * \return Error code, ERR_NONE on sucecss. 1528 */ 1529 GSM_Error GSM_WaitFor (GSM_StateMachine *s, unsigned const char *buffer, 1530 size_t length, int type, int timeout, 1531 GSM_Phone_RequestID request) WARNUNUSED; 1532 1533 /** 1534 * Wait for reply from the phone for ASCII strings without given length. 1535 * This is just a convenience wrapper around GSM_WaitFor which fills in 1536 * length. 1537 * 1538 * \param s State machine pointer. 1539 * \param buffer Data to write to phone. 1540 * \param type Type of request (for protocols where it makes sense). 1541 * \param timeout How long to wait for reply. 1542 * \param request ID of request 1543 * 1544 * \return Error code, ERR_NONE on sucecss. 1545 */ 1546 #define GSM_WaitForAutoLen(s,buffer,type,timeout,request) \ 1547 GSM_WaitFor(s,buffer,strlen(buffer),type,timeout,request) 1548 1549 GSM_Error GSM_DispatchMessage (GSM_StateMachine *s); 1550 1551 void GSM_DumpMessageText (GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type); 1552 void GSM_DumpMessageTextRecv (GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type); 1553 void GSM_DumpMessageBinary (GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type); 1554 void GSM_DumpMessageBinaryRecv(GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type); 1555 1556 1557 void GSM_OSErrorInfo(GSM_StateMachine *s, const char *description); 1558 1559 #endif 1560 /*@}*/ 1561 1562 /* How should editor hadle tabs in this file? Add editor commands here. 1563 * vim: noexpandtab sw=8 ts=8 sts=8: 1564 */ 1565