7 A Linux/Unix GUI for Nokia mobile phones.
8 Copyright (C) 1999 Pavel Janík ml., Hugh Blemings
9 & Ján Derfiòák <ja@mail.upjs.sk>.
11 Released under the terms of the GNU GPL, see file COPYING for more details.
14 Revision 1.1.1.1 2001/11/25 21:59:33 short
15 :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
17 Revision 1.19 2001/09/14 13:09:26 pkot
18 Xgnokii calendar updates
20 Revision 1.18 2001/06/20 21:27:36 pkot
21 IrDA patch (Martin Jancar)
23 Revision 1.17 2001/06/10 11:40:06 machek
24 xgnokii converted to new structure w.r.t. SMS messages.
26 Revision 1.16 2001/05/24 20:47:31 chris
27 More updating of 7110 code and some of xgnokii_lowlevel changed over.
29 Revision 1.15 2001/03/23 08:24:57 ja
30 New preview for 6210 in xgnokii's logos module.
32 Revision 1.14 2001/03/21 23:36:09 chris
33 Added the statemachine
34 This will break gnokii --identify and --monitor except for 6210/7110
36 Revision 1.13 2001/03/05 10:42:03 ja
37 Pavel Machek's vcard and finegrained indicators patch.
39 Revision 1.12 2001/02/02 08:09:57 ja
40 New dialogs for 6210/7110 in xgnokii. Fixed the smsd for new capabilty code.
42 Revision 1.11 2001/01/29 15:22:20 machek
43 Use integer as bitfield instead of struct of int:1.
45 Be able to read phonebook saved in gnokii format from xgnokii.
47 Revision 1.10 2001/01/17 02:54:56 chris
48 More 7110 work. Use with care! (eg it is not possible to delete phonebook entries)
49 I can now edit my phonebook in xgnokii but it is 'work in progress'.
51 Revision 1.9 2001/01/15 21:10:20 ja
52 Better status reporting in xgnokii, fixed phone capabilities detection in xgnokii.
62 #include "gsm-common.h"
64 #include "fbus-6110.h"
65 #include "fbus-3810.h"
66 #include "xgnokii_lowlevel.h"
68 #include "gsm-statemachine.h"
69 //#include "xgnokii_common.h"
72 PhoneMonitor phoneMonitor;
73 pthread_mutex_t memoryMutex;
74 pthread_cond_t memoryCond;
75 pthread_mutex_t calendarMutex;
76 pthread_cond_t calendarCond;
77 pthread_mutex_t smsMutex;
78 pthread_mutex_t sendSMSMutex;
79 pthread_cond_t sendSMSCond;
80 pthread_mutex_t callMutex;
81 pthread_mutex_t netMonMutex;
82 pthread_mutex_t speedDialMutex;
83 pthread_cond_t speedDialCond;
84 pthread_mutex_t callerGroupMutex;
85 pthread_cond_t callerGroupCond;
86 pthread_mutex_t smsCenterMutex;
87 pthread_cond_t smsCenterCond;
88 pthread_mutex_t alarmMutex;
89 pthread_cond_t alarmCond;
90 pthread_mutex_t getBitmapMutex;
91 pthread_cond_t getBitmapCond;
92 pthread_mutex_t setBitmapMutex;
93 pthread_cond_t setBitmapCond;
94 pthread_mutex_t getNetworkInfoMutex;
95 pthread_cond_t getNetworkInfoCond;
96 static pthread_mutex_t eventsMutex;
97 static GSList *ScheduledEvents = NULL;
99 static GSM_Statemachine statemachine;
100 /* FIXME - don't really know what should own the statemachine in */
101 /* the xgnokii scheme of things - Chris */
104 inline void GUI_InsertEvent (PhoneEvent *event)
107 g_print ("Inserting Event: %d\n", event->event);
109 pthread_mutex_lock (&eventsMutex);
110 ScheduledEvents = g_slist_prepend (ScheduledEvents, event);
111 pthread_mutex_unlock (&eventsMutex);
115 inline static PhoneEvent *RemoveEvent (void)
118 PhoneEvent *event = NULL;
120 pthread_mutex_lock (&eventsMutex);
121 list = g_slist_last (ScheduledEvents);
124 event = (PhoneEvent *) list->data;
125 ScheduledEvents = g_slist_remove_link (ScheduledEvents, list);
126 g_slist_free_1 (list);
128 pthread_mutex_unlock (&eventsMutex);
134 static void InitModelInf (void)
141 GSM_DataClear(&data);
143 while ((error = SM_Functions(GOP_GetModel,&data,&statemachine)) != GE_NONE && i++ < 15)
146 if (error == GE_NONE)
148 g_free (phoneMonitor.phone.model);
149 phoneMonitor.phone.version = g_strdup (buf);
150 phoneMonitor.phone.model = GetModel (buf);
151 if (phoneMonitor.phone.model == NULL)
152 phoneMonitor.phone.model = g_strdup (_("unknown"));
154 phoneMonitor.supported = GetPhoneModel(buf)->flags;
159 while ((error = SM_Functions(GOP_GetRevision,&data,&statemachine)) != GE_NONE && i++ < 5)
162 if (error == GE_NONE)
164 g_free (phoneMonitor.phone.revision);
165 phoneMonitor.phone.revision = g_strdup (buf);
170 while ((error = SM_Functions(GOP_GetImei,&data,&statemachine)) != GE_NONE && i++ < 5)
173 if (error == GE_NONE)
175 g_free (phoneMonitor.phone.imei);
176 phoneMonitor.phone.imei = g_strdup (buf);
181 g_print ("Version: %s\n", phoneMonitor.phone.version);
182 g_print ("Model: %s\n", phoneMonitor.phone.model);
183 g_print ("IMEI: %s\n", phoneMonitor.phone.imei);
184 g_print ("Revision: %s\n", phoneMonitor.phone.revision);
189 static GSM_Error fbusinit(bool enable_monitoring)
192 static GSM_Error error=GE_NOLINK;
193 GSM_ConnectionType connection=GCT_Serial;
195 if (!strcmp(xgnokiiConfig.connection, "infrared"))
196 connection = GCT_Infrared;
198 if (!strcmp(xgnokiiConfig.connection, "irda"))
199 connection = GCT_Irda;
201 /* Initialise the code for the GSM interface. */
203 if (error == GE_NOLINK)
204 error = GSM_Initialise (xgnokiiConfig.model, xgnokiiConfig.port,
205 xgnokiiConfig.initlength, connection, RLP_DisplayF96Frame, &statemachine);
208 g_print ("fbusinit: error %d\n", error);
211 if (error != GE_NONE) {
212 g_print (_("GSM/FBUS init failed! (Unknown model ?). Quitting.\n"));
213 /* FIXME: should popup some message... */
217 while (count++ < 40 && *GSM_LinkOK == false)
220 g_print("After usleep. GSM_LinkOK: %d\n", *GSM_LinkOK);
223 if (*GSM_LinkOK == true)
230 void GUI_InitPhoneMonitor (void)
232 phoneMonitor.phone.model = g_strdup (_("unknown"));
233 phoneMonitor.phone.version = phoneMonitor.phone.model;
234 phoneMonitor.phone.revision = g_strdup (_("unknown"));
235 phoneMonitor.phone.imei = g_strdup (_("unknown"));
236 phoneMonitor.supported = 0;
237 phoneMonitor.rfLevel = phoneMonitor.batteryLevel = -1;
238 phoneMonitor.powerSource = GPS_BATTERY;
239 phoneMonitor.working = NULL;
240 phoneMonitor.alarm = FALSE;
241 phoneMonitor.sms.unRead = phoneMonitor.sms.number = 0;
242 phoneMonitor.sms.messages = NULL;
243 phoneMonitor.call.callInProgress = CS_Idle;
244 *phoneMonitor.call.callNum = '\0';
245 phoneMonitor.netmonitor.number = 0;
246 *phoneMonitor.netmonitor.screen = *phoneMonitor.netmonitor.screen3 =
247 *phoneMonitor.netmonitor.screen4 = *phoneMonitor.netmonitor.screen5 = '\0';
248 pthread_mutex_init (&memoryMutex, NULL);
249 pthread_cond_init (&memoryCond, NULL);
250 pthread_mutex_init (&calendarMutex, NULL);
251 pthread_cond_init (&calendarCond, NULL);
252 pthread_mutex_init (&smsMutex, NULL);
253 pthread_mutex_init (&sendSMSMutex, NULL);
254 pthread_cond_init (&sendSMSCond, NULL);
255 pthread_mutex_init (&callMutex, NULL);
256 pthread_mutex_init (&eventsMutex, NULL);
257 pthread_mutex_init (&callMutex, NULL);
258 pthread_mutex_init (&netMonMutex, NULL);
259 pthread_mutex_init (&speedDialMutex, NULL);
260 pthread_cond_init (&speedDialCond, NULL);
261 pthread_mutex_init (&callerGroupMutex, NULL);
262 pthread_cond_init (&callerGroupCond, NULL);
263 pthread_mutex_init (&smsCenterMutex, NULL);
264 pthread_cond_init (&smsCenterCond, NULL);
265 pthread_mutex_init (&getBitmapMutex, NULL);
266 pthread_cond_init (&getBitmapCond, NULL);
267 pthread_mutex_init (&setBitmapMutex, NULL);
268 pthread_cond_init (&setBitmapCond, NULL);
269 pthread_mutex_init (&getNetworkInfoMutex, NULL);
270 pthread_cond_init (&getNetworkInfoCond, NULL);
274 static inline void FreeElement (gpointer data, gpointer userData)
276 g_free ((GSM_SMSMessage *) data);
280 static inline void FreeArray (GSList **array)
284 g_slist_foreach (*array, FreeElement, NULL);
285 g_slist_free (*array);
291 static void RefreshSMS (const gint number)
298 g_print ("RefreshSMS is running...\n");
301 pthread_mutex_lock (&smsMutex);
302 FreeArray (&(phoneMonitor.sms.messages));
303 phoneMonitor.sms.number = 0;
304 pthread_mutex_unlock (&smsMutex);
310 GSM_DataClear(&gdat);
311 msg = g_malloc (sizeof (GSM_SMSMessage));
312 msg->MemoryType = GMT_SM;
314 gdat.SMSMessage = msg;
316 if ((error = SM_Functions(GOP_GetSMS, &gdat, &statemachine)) == GE_NONE)
318 pthread_mutex_lock (&smsMutex);
319 phoneMonitor.sms.messages = g_slist_append (phoneMonitor.sms.messages, msg);
320 phoneMonitor.sms.number++;
321 pthread_mutex_unlock (&smsMutex);
322 if (phoneMonitor.sms.number == number)
325 else if (error == GE_INVALIDSMSLOCATION) /* All positions are readed */
338 static gint A_GetMemoryStatus (gpointer data)
341 D_MemoryStatus *ms = (D_MemoryStatus *) data;
344 error = ms->status = GE_UNKNOWN;
348 GSM_DataClear(&gdat);
349 pthread_mutex_lock (&memoryMutex);
350 gdat.MemoryStatus=&(ms->memoryStatus);
351 error = ms->status = SM_Functions(GOP_GetMemoryStatus,&gdat,&statemachine);
352 pthread_cond_signal (&memoryCond);
353 pthread_mutex_unlock (&memoryMutex);
360 static gint A_GetMemoryLocation (gpointer data)
363 D_MemoryLocation *ml = (D_MemoryLocation *) data;
366 error = ml->status = GE_UNKNOWN;
370 GSM_DataClear(&gdat);
371 pthread_mutex_lock (&memoryMutex);
372 gdat.PhonebookEntry=(ml->entry);
373 error = ml->status = SM_Functions(GOP_ReadPhonebook,&gdat,&statemachine);
374 pthread_cond_signal (&memoryCond);
375 pthread_mutex_unlock (&memoryMutex);
382 static gint A_GetMemoryLocationAll (gpointer data)
384 GSM_PhonebookEntry entry;
386 D_MemoryLocationAll *mla = (D_MemoryLocationAll *) data;
390 error = mla->status = GE_NONE;
391 entry.MemoryType = mla->type;
392 GSM_DataClear(&gdat);
393 gdat.PhonebookEntry=&entry;
395 pthread_mutex_lock (&memoryMutex);
396 for (i = mla->min; i <= mla->max; i++)
399 error = SM_Functions(GOP_ReadPhonebook,&gdat,&statemachine);
400 if (error != GE_NONE && error!=GE_INVALIDPHBOOKLOCATION)
404 while (error != GE_NONE)
406 g_print (_("%s: line %d: Can't get memory entry number %d from memory %d! %d\n"),
407 __FILE__, __LINE__, i, entry.MemoryType, error);
412 pthread_cond_signal (&memoryCond);
413 pthread_mutex_unlock (&memoryMutex);
417 error = SM_Functions(GOP_ReadPhonebook,&gdat,&statemachine);
422 /* If the phonebook location was invalid - just fill up the rest */
423 /* This works on a 7110 anyway...*/
425 if (error==GE_INVALIDPHBOOKLOCATION) {
429 for (i = mla->min; i <= mla->max; i++) {
430 error = mla->InsertEntry (&entry);
431 if (error != GE_NONE) break;
435 error = mla->InsertEntry (&entry);
436 if (error != GE_NONE)
440 pthread_cond_signal (&memoryCond);
441 pthread_mutex_unlock (&memoryMutex);
446 static gint A_WriteMemoryLocation (gpointer data)
449 D_MemoryLocation *ml = (D_MemoryLocation *) data;
452 error = ml->status = GE_UNKNOWN;
454 GSM_DataClear(&gdat);
455 gdat.PhonebookEntry=(ml->entry);
459 pthread_mutex_lock (&memoryMutex);
460 error = ml->status = SM_Functions(GOP_WritePhonebook,&gdat,&statemachine);
461 pthread_cond_signal (&memoryCond);
462 pthread_mutex_unlock (&memoryMutex);
469 static gint A_WriteMemoryLocationAll (gpointer data)
471 /* GSM_PhonebookEntry entry; */
473 D_MemoryLocationAll *mla = (D_MemoryLocationAll *) data;
476 error = mla->status = GE_NONE;
477 /* entry.MemoryType = mla->type;
479 pthread_mutex_lock (&memoryMutex);
480 for (i = mla->min; i <= mla->max; i++)
483 error = GSM->GetMemoryLocation (&entry);
484 if (error != GE_NONE)
488 while (error != GE_NONE)
490 g_print (_("%s: line %d: Can't get memory entry number %d from memory %d! %d\n"),
491 __FILE__, __LINE__, i, entry.MemoryType, error);
496 pthread_cond_signal (&memoryCond);
497 pthread_mutex_unlock (&memoryMutex);
501 error = GSM->GetMemoryLocation (&entry);
505 error = mla->InsertEntry (&entry);
506 if (error != GE_NONE)
510 pthread_cond_signal (&memoryCond);
511 pthread_mutex_unlock (&memoryMutex); */
516 static gint A_GetCalendarNote (gpointer data)
519 D_CalendarNote *cn = (D_CalendarNote *) data;
521 error = cn->status = GE_UNKNOWN;
525 pthread_mutex_lock (&calendarMutex);
526 error = cn->status = GSM->GetCalendarNote (cn->entry);
527 pthread_cond_signal (&calendarCond);
528 pthread_mutex_unlock (&calendarMutex);
535 static gint A_GetCalendarNoteAll (gpointer data)
537 GSM_CalendarNote entry;
538 D_CalendarNoteAll *cna = (D_CalendarNoteAll *) data;
542 pthread_mutex_lock (&calendarMutex);
545 entry.Location = i++;
547 if ((e = GSM->GetCalendarNote (&entry)) != GE_NONE)
550 if (cna->InsertEntry (&entry) != GE_NONE)
554 pthread_mutex_unlock (&calendarMutex);
556 if (e == GE_INVALIDCALNOTELOCATION)
563 static gint A_WriteCalendarNote (gpointer data)
566 D_CalendarNote *cn = (D_CalendarNote *) data;
568 error = cn->status = GE_UNKNOWN;
572 pthread_mutex_lock (&calendarMutex);
573 error = cn->status = GSM->WriteCalendarNote (cn->entry);
574 pthread_cond_signal (&calendarCond);
575 pthread_mutex_unlock (&calendarMutex);
582 static gint A_DeleteCalendarNote (gpointer data)
584 GSM_CalendarNote *note = (GSM_CalendarNote *) data;
585 GSM_Error error = GE_UNKNOWN;
589 error = GSM->DeleteCalendarNote (note);
596 static gint A_GetCallerGroup (gpointer data)
600 D_CallerGroup *cg = (D_CallerGroup *) data;
603 error = cg->status = GE_UNKNOWN;
607 bitmap.type = GSM_CallerLogo;
608 bitmap.number = cg->number;
610 pthread_mutex_lock (&callerGroupMutex);
611 GSM_DataClear(&gdat);
613 error = cg->status = SM_Functions(GOP_GetBitmap,&gdat,&statemachine);
614 strncpy (cg->text, bitmap.text, 256);
615 cg->text[255] = '\0';
616 pthread_cond_signal (&callerGroupCond);
617 pthread_mutex_unlock (&callerGroupMutex);
624 static gint A_SendCallerGroup (gpointer data)
627 D_CallerGroup *cg = (D_CallerGroup *) data;
633 bitmap.type = GSM_CallerLogo;
634 bitmap.number = cg->number;
635 if ((error = GSM->GetBitmap (&bitmap)) != GE_NONE)
640 strncpy (bitmap.text, cg->text, 256);
641 bitmap.text[255] = '\0';
643 return (GSM->SetBitmap (&bitmap));
647 static gint A_GetSMSCenter (gpointer data)
649 D_SMSCenter *c = (D_SMSCenter *) data;
652 error = c->status = GE_UNKNOWN;
655 pthread_mutex_lock (&smsCenterMutex);
656 error = c->status = GSM->GetSMSCenter (c->center);
657 pthread_cond_signal (&smsCenterCond);
658 pthread_mutex_unlock (&smsCenterMutex);
665 static gint A_SetSMSCenter (gpointer data)
667 D_SMSCenter *c = (D_SMSCenter *) data;
670 error = c->status = GE_UNKNOWN;
673 //pthread_mutex_lock (&smsCenterMutex);
674 error = c->status = GSM->SetSMSCenter (c->center);
676 //pthread_cond_signal (&smsCenterCond);
677 //pthread_mutex_unlock (&smsCenterMutex);
684 static gint A_SendSMSMessage (gpointer data)
686 D_SMSMessage *d = (D_SMSMessage *) data;
689 error = d->status = GE_UNKNOWN;
692 pthread_mutex_lock (&sendSMSMutex);
693 error = d->status = GSM->SendSMSMessage (d->sms, 0);
694 pthread_cond_signal (&sendSMSCond);
695 pthread_mutex_unlock (&sendSMSMutex);
698 if (d->status == GE_SMSSENDOK)
705 static gint A_DeleteSMSMessage (gpointer data)
707 GSM_SMSMessage *sms = (GSM_SMSMessage *) data;
708 GSM_Error error = GE_UNKNOWN;
713 GSM_DataClear(&gdat);
714 gdat.SMSMessage = sms;
715 error = SM_Functions(GOP_DeleteSMS, &gdat, &statemachine);
723 static gint A_GetSpeedDial (gpointer data)
725 D_SpeedDial *d = (D_SpeedDial *) data;
728 error = d->status = GE_UNKNOWN;
732 pthread_mutex_lock (&speedDialMutex);
733 error = d->status = GSM->GetSpeedDial (&(d->entry));
734 pthread_cond_signal (&speedDialCond);
735 pthread_mutex_unlock (&speedDialMutex);
742 static gint A_SendSpeedDial (gpointer data)
744 D_SpeedDial *d = (D_SpeedDial *) data;
747 error = d->status = GE_UNKNOWN;
751 //pthread_mutex_lock (&speedDialMutex);
752 error = d->status = GSM->SetSpeedDial (&(d->entry));
754 //pthread_cond_signal (&speedDialCond);
755 //pthread_mutex_unlock (&speedDialMutex);
762 static gint A_SendDTMF (gpointer data)
764 gchar *buf = (gchar *) data;
765 GSM_Error error = GE_UNKNOWN;
769 error = GSM->SendDTMF (buf);
777 static gint A_NetMonOnOff (gpointer data)
780 gint mode = GPOINTER_TO_INT (data);
781 GSM_Error error = GE_UNKNOWN;
784 error = GSM->NetMonitor (0xf3, screen);
786 error = GSM->NetMonitor (0xf1, screen);
792 static gint A_NetMonitor (gpointer data)
794 gint number = GPOINTER_TO_INT (data);
797 phoneMonitor.netmonitor.number = 0;
799 phoneMonitor.netmonitor.number = number;
805 static gint A_DialVoice (gpointer data)
807 gchar *number = (gchar *) data;
808 GSM_Error error = GE_UNKNOWN;
812 error = GSM->DialVoice (number);
820 static gint A_GetAlarm (gpointer data)
822 D_Alarm *a = (D_Alarm *) data;
829 a->status = GE_UNKNOWN;
830 pthread_mutex_lock (&alarmMutex);
831 error = a->status = GSM->GetAlarm (0, &(a->time));
832 pthread_cond_signal (&alarmCond);
833 pthread_mutex_unlock (&alarmMutex);
840 static gint A_SetAlarm (gpointer data)
842 D_Alarm *a = (D_Alarm *) data;
845 error = a->status = GE_UNKNOWN;
849 error = a->status = GSM->SetAlarm (0, &(a->time));
857 static gint A_SendKeyStroke (gpointer data)
859 gchar *buf = (gchar *) data;
863 FB61_TX_SendMessage(0x07, 0x0c, buf);
870 static gint A_GetBitmap(gpointer data) {
872 D_Bitmap *d = (D_Bitmap *)data;
875 GSM_DataClear(&gdat);
876 pthread_mutex_lock(&getBitmapMutex);
877 gdat.Bitmap=d->bitmap;
878 error = d->status = SM_Functions(GOP_GetBitmap,&gdat,&statemachine);
879 pthread_cond_signal(&getBitmapCond);
880 pthread_mutex_unlock(&getBitmapMutex);
884 static gint A_SetBitmap(gpointer data) {
886 D_Bitmap *d = (D_Bitmap *)data;
890 GSM_DataClear(&gdat);
891 pthread_mutex_lock(&setBitmapMutex);
892 if (d->bitmap->type == GSM_CallerLogo) {
893 bitmap.type = d->bitmap->type;
894 bitmap.number = d->bitmap->number;
896 error = d->status = SM_Functions(GOP_GetBitmap,&gdat,&statemachine);
897 if (error == GE_NONE) {
898 strncpy(d->bitmap->text,bitmap.text,sizeof(bitmap.text));
899 d->bitmap->ringtone = bitmap.ringtone;
900 gdat.Bitmap=d->bitmap;
901 error = d->status = SM_Functions(GOP_SetBitmap,&gdat,&statemachine);
904 gdat.Bitmap=d->bitmap;
905 error = d->status = SM_Functions(GOP_SetBitmap,&gdat,&statemachine);
907 pthread_cond_signal(&setBitmapCond);
908 pthread_mutex_unlock(&setBitmapMutex);
912 static gint A_GetNetworkInfo(gpointer data) {
914 D_NetworkInfo *d = (D_NetworkInfo *)data;
917 GSM_DataClear(&gdat);
919 pthread_mutex_lock(&getNetworkInfoMutex);
920 gdat.NetworkInfo=d->info;
921 error = d->status = SM_Functions(GOP_GetNetworkInfo,&gdat,&statemachine);
922 pthread_cond_signal(&getNetworkInfoCond);
923 pthread_mutex_unlock(&getNetworkInfoMutex);
927 static gint A_Exit (gpointer data)
930 return (0); /* just to be proper */
934 gint (*DoAction[])(gpointer) = {
937 A_GetMemoryLocationAll,
938 A_WriteMemoryLocation,
939 A_WriteMemoryLocationAll,
941 A_GetCalendarNoteAll,
943 A_DeleteCalendarNote,
966 void *GUI_Connect (void *a)
968 /* Define required unit types for RF and Battery level meters. */
969 GSM_RFUnits rf_units = GRF_Percentage;
970 GSM_BatteryUnits batt_units = GBU_Percentage;
973 GSM_SMSStatus SMSStatus = {0, 0};
974 gchar number[INCALL_NUMBER_LENGTH];
980 GSM_DataClear(&data);
983 g_print ("Initializing connection...\n");
986 phoneMonitor.working = _("Connecting...");
987 while (!fbusinit (true))
991 g_print ("Phone connected. Starting monitoring...\n");
996 data.RFLevel=&phoneMonitor.rfLevel;
997 data.RFUnits=&rf_units;
998 data.PowerSource=&phoneMonitor.powerSource;
999 data.BatteryUnits=&batt_units;
1000 data.BatteryLevel=&phoneMonitor.batteryLevel;
1001 data.DateTime=&Alarm;
1002 data.SMSStatus=&SMSStatus;
1003 data.IncomingCallNr=number;
1007 phoneMonitor.working = NULL;
1009 /* FIXME - this loop goes mad on my 7110 - so I've put in a usleep */
1012 if (SM_Functions(GOP_GetRFLevel,&data,&statemachine) != GE_NONE)
1013 phoneMonitor.rfLevel = -1;
1015 if (rf_units == GRF_Arbitrary)
1016 phoneMonitor.rfLevel *= 25;
1018 if (SM_Functions(GOP_GetPowersource,&data,&statemachine) == GE_NONE
1019 && phoneMonitor.powerSource == GPS_ACDC)
1020 phoneMonitor.batteryLevel = ((gint) phoneMonitor.batteryLevel + 25) % 125;
1023 if (SM_Functions(GOP_GetBatteryLevel,&data,&statemachine) != GE_NONE)
1024 phoneMonitor.batteryLevel = -1;
1025 if (batt_units == GBU_Arbitrary)
1026 phoneMonitor.batteryLevel *= 25;
1029 if (SM_Functions(GOP_GetAlarm,&data,&statemachine) == GE_NONE && Alarm.AlarmEnabled != 0)
1030 phoneMonitor.alarm = TRUE;
1032 phoneMonitor.alarm = FALSE;
1034 if (SM_Functions(GOP_GetSMSStatus,&data,&statemachine) == GE_NONE)
1036 if (phoneMonitor.sms.unRead != SMSStatus.UnRead ||
1037 phoneMonitor.sms.number != SMSStatus.Number)
1039 phoneMonitor.working = _("Refreshing SMSes...");
1040 RefreshSMS (SMSStatus.Number);
1041 phoneMonitor.working = NULL;
1044 phoneMonitor.sms.unRead = SMSStatus.UnRead;
1047 if (SM_Functions(GOP_GetIncomingCallNr,&data,&statemachine) == GE_NONE)
1050 g_print ("Call in progress: %s\n", phoneMonitor.call.callNum);
1053 GSM->GetDisplayStatus (&status);
1054 if (status & (1<<DS_Call_In_Progress))
1056 pthread_mutex_lock (&callMutex);
1057 phoneMonitor.call.callInProgress = CS_InProgress;
1058 pthread_mutex_unlock (&callMutex);
1062 pthread_mutex_lock (&callMutex);
1063 phoneMonitor.call.callInProgress = CS_Waiting;
1064 strncpy (phoneMonitor.call.callNum, number, INCALL_NUMBER_LENGTH);
1065 pthread_mutex_unlock (&callMutex);
1070 pthread_mutex_lock (&callMutex);
1071 phoneMonitor.call.callInProgress = CS_Idle;
1072 *phoneMonitor.call.callNum = '\0';
1073 pthread_mutex_unlock (&callMutex);
1076 pthread_mutex_lock (&netMonMutex);
1077 if (phoneMonitor.netmonitor.number)
1079 GSM->NetMonitor (phoneMonitor.netmonitor.number,
1080 phoneMonitor.netmonitor.screen);
1081 GSM->NetMonitor (3, phoneMonitor.netmonitor.screen3);
1082 GSM->NetMonitor (4, phoneMonitor.netmonitor.screen4);
1083 GSM->NetMonitor (5, phoneMonitor.netmonitor.screen5);
1087 *phoneMonitor.netmonitor.screen = *phoneMonitor.netmonitor.screen3 =
1088 *phoneMonitor.netmonitor.screen4 = *phoneMonitor.netmonitor.screen5 = '\0';
1090 pthread_mutex_unlock (&netMonMutex);
1092 while ((event = RemoveEvent ()) != NULL)
1095 g_print ("Processing Event: %d\n", event->event);
1097 phoneMonitor.working = _("Working...");
1098 if (event->event <= Event_Exit)
1099 if ((error = DoAction[event->event] (event->data)) != GE_NONE)
1100 g_print (_("Event %d failed with return code %d!\n"), event->event, error);