gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Motorola C350 patch 2


From: Pawel Kot
Subject: Re: Motorola C350 patch 2
Date: Thu, 19 Feb 2004 00:02:15 +0100 (CET)

On Sun, 15 Feb 2004, Ron Yorston wrote:

> As a further step in getting the Motorola C350 to work with xgnokii
> here's a patch which calculates the number of free/used phonebook
> entries after the contents of the phonebook have been read.  This is
> necessary because the C350 doesn't report the number of used/total
> entries in response to a '+CPBS?' query.

Looks good. And Work For Me (TM). Just two notes: it is not necessary to
recount free/used unconditionally.

There's above:
if (ms->status != GN_ERR_NONE) {
we can set there some local variable:
        has_memory_stats = false;
and
if (!has_memory_stats) {
        [your code]
}

We'd kill that ugly fbus3810 variable as well. What do you think? Patch
against CVS follows. I should have Hugh's 3810 somewhere where so I'll
test the phone later.

Index: xgnokii/xgnokii_contacts.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/xgnokii/xgnokii_contacts.c,v
retrieving revision 1.55
diff -u -r1.55 xgnokii_contacts.c
--- xgnokii/xgnokii_contacts.c  17 Feb 2004 21:33:44 -0000      1.55
+++ xgnokii/xgnokii_contacts.c  18 Feb 2004 23:00:46 -0000
@@ -82,7 +82,6 @@
 } ExtPbkDialog;

 static GtkWidget *GUI_ContactsWindow;
-static bool fbus3810;
 static bool contactsMemoryInitialized;
 static MemoryStatus memoryStatus;
 static ContactsMemory contactsMemory;  /* Hold contacts. */
@@ -2387,10 +2386,6 @@
                pbEntry->status = E_Empty;
        else {
                pbEntry->status = E_Unchanged;
-               if (fbus3810) {
-                       memoryStatus.UsedSM++;
-                       memoryStatus.FreeSM--;
-               }
        }

        g_ptr_array_add(contactsMemory, (gpointer) pbEntry);
@@ -2416,8 +2411,7 @@
        D_MemoryLocationAll *mla;
        PhonebookEntry *pbEntry;
        register gint i;
-
-       fbus3810 = FALSE;
+       bool has_memory_stats = true;

        if (contactsMemoryInitialized == TRUE) {
                for (i = 0; i < memoryStatus.MaxME + memoryStatus.MaxSM; i++) {
@@ -2463,12 +2457,7 @@
        pthread_mutex_unlock(&memoryMutex);

        if (ms->status != GN_ERR_NONE) {
-               fbus3810 = TRUE;        /* I try to recognize 
memoryStatus.UsedSM while reading */
-               gtk_label_set_text(GTK_LABEL(errorDialog.text), _("Can't get SM 
memory status!\n\n\
-Setting max SIM entries to 100!\n"));
-               memoryStatus.MaxSM = memoryStatus.FreeSM = 100;
-               memoryStatus.UsedSM = 0;
-               gtk_widget_show(errorDialog.dialog);
+               has_memory_stats = false;
        } else {
                memoryStatus.MaxSM = ms->memoryStatus.used + 
ms->memoryStatus.free;
                memoryStatus.UsedSM = ms->memoryStatus.used;
@@ -2513,6 +2502,19 @@
                        gtk_widget_hide(progressDialog.dialog);
                        return;
                }
+
+               if (!has_memory_stats) {
+                       memoryStatus.FreeME = memoryStatus.UsedME = 0;
+                       for (i = 0; i < memoryStatus.MaxME; i++) {
+                               pbEntry = g_ptr_array_index(contactsMemory, i);
+
+                               if (pbEntry->status == E_Empty)
+                                       memoryStatus.FreeME++;
+                               else
+                                       memoryStatus.UsedME++;
+                       }
+                       RefreshStatusInfo();
+               }
        }

        mla->min = 1;
@@ -2534,6 +2536,19 @@
                g_free(mla);
                gtk_widget_hide(progressDialog.dialog);
                return;
+       }
+
+       if (!has_memory_stats) {
+               memoryStatus.FreeSM = memoryStatus.UsedSM = 0;
+               for (i = memoryStatus.MaxME; i < 
memoryStatus.MaxME+memoryStatus.MaxSM; i++) {
+                       pbEntry = g_ptr_array_index(contactsMemory, i);
+
+                       if (pbEntry->status == E_Empty)
+                               memoryStatus.FreeSM++;
+                       else
+                               memoryStatus.UsedSM++;
+               }
+               RefreshStatusInfo();
        }

        g_free(mla);

pkot
-- 
mailto:address@hidden
http://www.gnokii.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]