Released under the terms of the GNU GPL, see file COPYING for more details.
$Log$
- Revision 1.1.1.1 2001/11/25 21:59:33 short
- :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
+ Revision 1.1.1.4 2002/04/03 00:08:33 short
+ Found in "gnokii-working" directory, some November-patches version
Revision 1.19 2001/09/14 13:09:26 pkot
Xgnokii calendar updates
pthread_mutex_t smsMutex;
pthread_mutex_t sendSMSMutex;
pthread_cond_t sendSMSCond;
+pthread_mutex_t saveSMSMutex;
+pthread_cond_t saveSMSCond;
pthread_mutex_t callMutex;
pthread_mutex_t netMonMutex;
pthread_mutex_t speedDialMutex;
static pthread_mutex_t eventsMutex;
static GSList *ScheduledEvents = NULL;
-static GSM_Statemachine statemachine;
-/* FIXME - don't really know what should own the statemachine in */
-/* the xgnokii scheme of things - Chris */
+/* This symbol must be export as it is (mis)used by xgnokii_logos.c
+ */
+GSM_Statemachine xgnokii_statemachine;
inline void GUI_InsertEvent (PhoneEvent *event)
GSM_DataClear(&data);
data.Model=buf;
- while ((error = SM_Functions(GOP_GetModel,&data,&statemachine)) != GE_NONE && i++ < 15)
+ while ((error = SM_Functions(GOP_GetModel,&data,&xgnokii_statemachine)) != GE_NONE && i++ < 15)
sleep(1);
if (error == GE_NONE)
i = 0;
data.Revision=buf;
- while ((error = SM_Functions(GOP_GetRevision,&data,&statemachine)) != GE_NONE && i++ < 5)
+ while ((error = SM_Functions(GOP_GetRevision,&data,&xgnokii_statemachine)) != GE_NONE && i++ < 5)
sleep(1);
if (error == GE_NONE)
i = 0;
data.Imei=buf;
- while ((error = SM_Functions(GOP_GetImei,&data,&statemachine)) != GE_NONE && i++ < 5)
+ while ((error = SM_Functions(GOP_GetImei,&data,&xgnokii_statemachine)) != GE_NONE && i++ < 5)
sleep(1);
if (error == GE_NONE)
static GSM_Error fbusinit(bool enable_monitoring)
{
int count=0;
- static GSM_Error error=GE_NOLINK;
+ GSM_Error error=GE_NOLINK;
GSM_ConnectionType connection=GCT_Serial;
if (!strcmp(xgnokiiConfig.connection, "infrared"))
if (error == GE_NOLINK)
error = GSM_Initialise (xgnokiiConfig.model, xgnokiiConfig.port,
- xgnokiiConfig.initlength, connection, RLP_DisplayF96Frame, &statemachine);
+ xgnokiiConfig.initlength, connection, NULL /*RLP_DisplayF96Frame*/, &xgnokii_statemachine);
#ifdef XDEBUG
g_print ("fbusinit: error %d\n", error);
g_print("After usleep. GSM_LinkOK: %d\n", *GSM_LinkOK);
#endif
- if (*GSM_LinkOK == true)
- InitModelInf ();
+ if (*GSM_LinkOK != true) {
+ return (GE_NOLINK);
+ }
- return *GSM_LinkOK;
+ InitModelInf ();
+ return(GE_NONE);
}
phoneMonitor.powerSource = GPS_BATTERY;
phoneMonitor.working = NULL;
phoneMonitor.alarm = FALSE;
- phoneMonitor.sms.unRead = phoneMonitor.sms.number = 0;
+ phoneMonitor.sms.unRead = phoneMonitor.sms.used = phoneMonitor.sms.slots = 0;
phoneMonitor.sms.messages = NULL;
phoneMonitor.call.callInProgress = CS_Idle;
*phoneMonitor.call.callNum = '\0';
pthread_mutex_init (&smsMutex, NULL);
pthread_mutex_init (&sendSMSMutex, NULL);
pthread_cond_init (&sendSMSCond, NULL);
+ pthread_mutex_init (&saveSMSMutex, NULL);
+ pthread_cond_init (&saveSMSCond, NULL);
pthread_mutex_init (&callMutex, NULL);
pthread_mutex_init (&eventsMutex, NULL);
pthread_mutex_init (&callMutex, NULL);
}
-static void RefreshSMS (const gint number)
+static void RefreshSMS (const gint slots)
{
GSM_Error error;
GSM_SMSMessage *msg;
register gint i;
+ gint unread = 0;
# ifdef XDEBUG
g_print ("RefreshSMS is running...\n");
pthread_mutex_lock (&smsMutex);
FreeArray (&(phoneMonitor.sms.messages));
- phoneMonitor.sms.number = 0;
+ phoneMonitor.sms.used = 0;
pthread_mutex_unlock (&smsMutex);
- i = 0;
- while (1)
+ for (i=1; i<=slots; i++)
{
GSM_Data gdat;
GSM_DataClear(&gdat);
msg = g_malloc (sizeof (GSM_SMSMessage));
msg->MemoryType = GMT_SM;
- msg->Location = ++i;
+ msg->Location = i;
gdat.SMSMessage = msg;
- if ((error = SM_Functions(GOP_GetSMS, &gdat, &statemachine)) == GE_NONE)
+ if ((error = SM_Functions(GOP_GetSMS, &gdat, &xgnokii_statemachine)) == GE_NONE)
{
pthread_mutex_lock (&smsMutex);
phoneMonitor.sms.messages = g_slist_append (phoneMonitor.sms.messages, msg);
- phoneMonitor.sms.number++;
+ phoneMonitor.sms.used++;
+ if (msg->Type == GST_MT && msg->Status == GSS_NOTSENTREAD)
+ unread++;
pthread_mutex_unlock (&smsMutex);
- if (phoneMonitor.sms.number == number)
- return;
}
else if (error == GE_INVALIDSMSLOCATION) /* All positions are readed */
{
else
g_free (msg);
- usleep (750000);
+ /* FIXME: Why is any delay here?
+ */
+ /* usleep (750000); */
}
+ /* Update it after the whole run as otherwise "Refreshing SMSes..."
+ * would collide with "Short Message received" message.
+ */
+ phoneMonitor.sms.unRead = unread;
}
GSM_DataClear(&gdat);
pthread_mutex_lock (&memoryMutex);
gdat.MemoryStatus=&(ms->memoryStatus);
- error = ms->status = SM_Functions(GOP_GetMemoryStatus,&gdat,&statemachine);
+ error = ms->status = SM_Functions(GOP_GetMemoryStatus,&gdat,&xgnokii_statemachine);
pthread_cond_signal (&memoryCond);
pthread_mutex_unlock (&memoryMutex);
}
GSM_DataClear(&gdat);
pthread_mutex_lock (&memoryMutex);
gdat.PhonebookEntry=(ml->entry);
- error = ml->status = SM_Functions(GOP_ReadPhonebook,&gdat,&statemachine);
+ error = ml->status = SM_Functions(GOP_ReadPhonebook,&gdat,&xgnokii_statemachine);
pthread_cond_signal (&memoryCond);
pthread_mutex_unlock (&memoryMutex);
}
for (i = mla->min; i <= mla->max; i++)
{
entry.Location = i;
- error = SM_Functions(GOP_ReadPhonebook,&gdat,&statemachine);
+ error = SM_Functions(GOP_ReadPhonebook,&gdat,&xgnokii_statemachine);
if (error != GE_NONE && error!=GE_INVALIDPHBOOKLOCATION)
{
gint err_count = 0;
return (error);
}
- error = SM_Functions(GOP_ReadPhonebook,&gdat,&statemachine);
+ error = SM_Functions(GOP_ReadPhonebook,&gdat,&xgnokii_statemachine);
sleep (2);
}
}
if (ml)
{
pthread_mutex_lock (&memoryMutex);
- error = ml->status = SM_Functions(GOP_WritePhonebook,&gdat,&statemachine);
+ error = ml->status = SM_Functions(GOP_WritePhonebook,&gdat,&xgnokii_statemachine);
pthread_cond_signal (&memoryCond);
pthread_mutex_unlock (&memoryMutex);
}
pthread_mutex_lock (&callerGroupMutex);
GSM_DataClear(&gdat);
gdat.Bitmap=&bitmap;
- error = cg->status = SM_Functions(GOP_GetBitmap,&gdat,&statemachine);
+ error = cg->status = SM_Functions(GOP_GetBitmap,&gdat,&xgnokii_statemachine);
strncpy (cg->text, bitmap.text, 256);
cg->text[255] = '\0';
pthread_cond_signal (&callerGroupCond);
if (d)
{
pthread_mutex_lock (&sendSMSMutex);
- error = d->status = GSM->SendSMSMessage (d->sms, 0);
+ error = d->status = GSM->SendSMSMessage (d->sms);
pthread_cond_signal (&sendSMSCond);
pthread_mutex_unlock (&sendSMSMutex);
}
}
+static gint A_SaveSMSMessage (gpointer data)
+{
+ D_SMSMessage *d = (D_SMSMessage *) data;
+ GSM_Error error;
+
+ error = d->status = GE_UNKNOWN;
+ if (d)
+ {
+ pthread_mutex_lock (&saveSMSMutex);
+ error = d->status = GSM->SaveSMSMessage (d->sms);
+ pthread_cond_signal (&saveSMSCond);
+ pthread_mutex_unlock (&saveSMSMutex);
+ }
+
+ return (error);
+}
+
+
static gint A_DeleteSMSMessage (gpointer data)
{
GSM_SMSMessage *sms = (GSM_SMSMessage *) data;
GSM_Data gdat;
GSM_DataClear(&gdat);
gdat.SMSMessage = sms;
- error = SM_Functions(GOP_DeleteSMS, &gdat, &statemachine);
+ error = SM_Functions(GOP_DeleteSMS, &gdat, &xgnokii_statemachine);
g_free (sms);
}
error = GE_UNKNOWN;
- if (a)
+ if (a && GSM)
{
a->status = GE_UNKNOWN;
pthread_mutex_lock (&alarmMutex);
if (buf)
{
+#if 0
FB61_TX_SendMessage(0x07, 0x0c, buf);
+#endif
g_free (buf);
}
GSM_DataClear(&gdat);
pthread_mutex_lock(&getBitmapMutex);
gdat.Bitmap=d->bitmap;
- error = d->status = SM_Functions(GOP_GetBitmap,&gdat,&statemachine);
+ error = d->status = SM_Functions(GOP_GetBitmap,&gdat,&xgnokii_statemachine);
pthread_cond_signal(&getBitmapCond);
pthread_mutex_unlock(&getBitmapMutex);
return error;
bitmap.type = d->bitmap->type;
bitmap.number = d->bitmap->number;
gdat.Bitmap=&bitmap;
- error = d->status = SM_Functions(GOP_GetBitmap,&gdat,&statemachine);
+ error = d->status = SM_Functions(GOP_GetBitmap,&gdat,&xgnokii_statemachine);
if (error == GE_NONE) {
strncpy(d->bitmap->text,bitmap.text,sizeof(bitmap.text));
d->bitmap->ringtone = bitmap.ringtone;
gdat.Bitmap=d->bitmap;
- error = d->status = SM_Functions(GOP_SetBitmap,&gdat,&statemachine);
+ error = d->status = SM_Functions(GOP_SetBitmap,&gdat,&xgnokii_statemachine);
}
} else {
gdat.Bitmap=d->bitmap;
- error = d->status = SM_Functions(GOP_SetBitmap,&gdat,&statemachine);
+ error = d->status = SM_Functions(GOP_SetBitmap,&gdat,&xgnokii_statemachine);
}
pthread_cond_signal(&setBitmapCond);
pthread_mutex_unlock(&setBitmapMutex);
pthread_mutex_lock(&getNetworkInfoMutex);
gdat.NetworkInfo=d->info;
- error = d->status = SM_Functions(GOP_GetNetworkInfo,&gdat,&statemachine);
+ error = d->status = SM_Functions(GOP_GetNetworkInfo,&gdat,&xgnokii_statemachine);
pthread_cond_signal(&getNetworkInfoCond);
pthread_mutex_unlock(&getNetworkInfoMutex);
return error;
A_GetSMSCenter,
A_SetSMSCenter,
A_SendSMSMessage,
+ A_SaveSMSMessage,
A_DeleteSMSMessage,
A_GetSpeedDial,
A_SendSpeedDial,
GSM_BatteryUnits batt_units = GBU_Percentage;
GSM_DateTime Alarm;
- GSM_SMSStatus SMSStatus = {0, 0};
+ GSM_SMSStatus SMSStatus = {0, 0, 0};
gchar number[INCALL_NUMBER_LENGTH];
PhoneEvent *event;
GSM_Error error;
# endif
phoneMonitor.working = _("Connecting...");
- while (!fbusinit (true))
+ while (fbusinit (true))
sleep (1);
# ifdef XDEBUG
/* FIXME - this loop goes mad on my 7110 - so I've put in a usleep */
usleep(50000);
- if (SM_Functions(GOP_GetRFLevel,&data,&statemachine) != GE_NONE)
+ if (SM_Functions(GOP_GetRFLevel,&data,&xgnokii_statemachine) != GE_NONE)
phoneMonitor.rfLevel = -1;
if (rf_units == GRF_Arbitrary)
phoneMonitor.rfLevel *= 25;
- if (SM_Functions(GOP_GetPowersource,&data,&statemachine) == GE_NONE
+ if (SM_Functions(GOP_GetPowersource,&data,&xgnokii_statemachine) == GE_NONE
&& phoneMonitor.powerSource == GPS_ACDC)
- phoneMonitor.batteryLevel = ((gint) phoneMonitor.batteryLevel + 25) % 125;
- else
{
- if (SM_Functions(GOP_GetBatteryLevel,&data,&statemachine) != GE_NONE)
+ if (phoneMonitor.batteryLevel < 0 || phoneMonitor.batteryLevel > 100)
+ phoneMonitor.batteryLevel = 100;
+ }
+ else {
+ if (SM_Functions(GOP_GetBatteryLevel,&data,&xgnokii_statemachine) != GE_NONE)
phoneMonitor.batteryLevel = -1;
if (batt_units == GBU_Arbitrary)
phoneMonitor.batteryLevel *= 25;
}
- if (SM_Functions(GOP_GetAlarm,&data,&statemachine) == GE_NONE && Alarm.AlarmEnabled != 0)
+ if (SM_Functions(GOP_GetAlarm,&data,&xgnokii_statemachine) == GE_NONE && Alarm.AlarmEnabled != 0)
phoneMonitor.alarm = TRUE;
else
phoneMonitor.alarm = FALSE;
- if (SM_Functions(GOP_GetSMSStatus,&data,&statemachine) == GE_NONE)
+ if (SM_Functions(GOP_GetSMSStatus,&data,&xgnokii_statemachine) == GE_NONE)
{
+ /* Change of "UnRead" shouldn't be interesting - user may have read some of his
+ * SMSes by the phone interface.
+ */
if (phoneMonitor.sms.unRead != SMSStatus.UnRead ||
- phoneMonitor.sms.number != SMSStatus.Number)
+ phoneMonitor.sms.used != SMSStatus.Used ||
+ phoneMonitor.sms.slots != SMSStatus.Slots) /* shouldn't change, just to be sure */
{
+ /* We are primarily interested in SMSStatus.Slots so try to fix it up if it is broken
+ */
+ if (SMSStatus.UnRead > SMSStatus.Used)
+ SMSStatus.Used = SMSStatus.UnRead;
+ if (SMSStatus.Used > SMSStatus.Slots)
+ SMSStatus.Slots = SMSStatus.Used;
+ phoneMonitor.sms.slots = SMSStatus.Slots; /* shouldn't change, just to be sure */
+ /* phoneMonitor.sms.{unRead,used} will be updated by RefreshSMS()
+ */
+
phoneMonitor.working = _("Refreshing SMSes...");
- RefreshSMS (SMSStatus.Number);
+ RefreshSMS (SMSStatus.Slots);
phoneMonitor.working = NULL;
}
- phoneMonitor.sms.unRead = SMSStatus.UnRead;
}
- if (SM_Functions(GOP_GetIncomingCallNr,&data,&statemachine) == GE_NONE)
+ if (SM_Functions(GOP_GetIncomingCallNr,&data,&xgnokii_statemachine) == GE_NONE)
{
# ifdef XDEBUG
g_print ("Call in progress: %s\n", phoneMonitor.call.callNum);