http://marcin-wiacek.fkn.pl/english/zips/mygnokii.tar.gz
[gnokii.git] / xgnokii / xgnokii_contacts.c
index c34d5f7..39ef62b 100644 (file)
@@ -3,42 +3,11 @@
   X G N O K I I
 
   A Linux/Unix GUI for Nokia mobile phones.
-  Copyright (C) 1999 Pavel Janík ml., Hugh Blemings
-  & Ján Derfiòák <ja@mail.upjs.sk>.
 
   Released under the terms of the GNU GPL, see file COPYING for more details.
 
   $Id$
   
-  $Log$
-  Revision 1.1.1.1  2001/11/25 21:59:28  short
-  :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
-
-  Revision 1.31  2001/11/14 10:46:12  pkot
-  Small cleanup with __unices__
-
-  Revision 1.30  2001/09/14 13:14:04  pkot
-  Xgnokii WM fixes (Martin Lucina)
-
-  Revision 1.29  2001/03/23 08:24:56  ja
-  New preview for 6210 in xgnokii's logos module.
-
-  Revision 1.28  2001/03/19 23:43:47  pkot
-  Solaris/BSD '#if defined' cleanup
-
-  Revision 1.27  2001/03/13 01:21:39  pkot
-  *BSD updates (Bert Driehuis)
-
-  Revision 1.26  2001/03/05 10:42:03  ja
-  Pavel Machek's vcard and finegrained indicators patch.
-
-  Revision 1.25  2001/02/12 15:13:46  chris
-  Fixed my bug in xgnokii_contacts.c and added <string.h> to tekram.c
-
-  Revision 1.24  2001/02/02 08:09:57  ja
-  New dialogs for 6210/7110 in xgnokii. Fixed the smsd for new capabilty code.
-
-  
 */
 
 
 
 #include <stdlib.h>
 #include <string.h>
+#if __unices__
+# include <strings.h>
+#endif
 #include <gtk/gtk.h>
 
+#include "gsm-api.h"
 #include "gsm-common.h"
 #include "xgnokii_contacts.h"
 #include "xgnokii_lowlevel.h"
@@ -278,7 +251,7 @@ static void OkEditEntryDialog (GtkWidget *widget, gpointer data)
             max_phonebook_name_length);
     entry->entry.Name[max_phonebook_name_length] = '\0';
 
-    if (phoneMonitor.supported & PM_EXTPBK)
+    if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT)
     {
     }
     else
@@ -324,7 +297,7 @@ because you save it into SIM memory!"));
       gtk_widget_show (errorDialog.dialog);
     }
 
-    if (phoneMonitor.supported & PM_EXTPBK)
+    if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT)
     {
     }
     else
@@ -358,7 +331,7 @@ because you save it into SIM memory!"));
               max_phonebook_name_length);
       ((EditEntryData*) data)->pbEntry->entry.Name[max_phonebook_name_length] = '\0';
 
-      if (phoneMonitor.supported & PM_EXTPBK)
+      if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT)
       {
       }
       else
@@ -383,7 +356,7 @@ because you save it into SIM memory!"));
         gtk_widget_show (errorDialog.dialog);
       }
 
-      if (phoneMonitor.supported & PM_EXTPBK)
+      if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT)
       {
       }
       else
@@ -420,7 +393,7 @@ because you save it into SIM memory!"));
     clist_row[2] = "P";
   else
     clist_row[2] = "S";
-  if (phoneMonitor.supported & PM_CALLERGROUP)
+  if (GetModelFeature(FN_CALLERGROUPS)!=0)
     clist_row[3] = xgnokiiConfig.callerGroups[((EditEntryData*) data)->pbEntry->entry.Group];
   else
     clist_row[3] = "";
@@ -500,7 +473,7 @@ static void OkNewEntryDialog(GtkWidget *widget, gpointer data )
             max_phonebook_name_length);
     entry->entry.Name[max_phonebook_name_length] = '\0';
 
-    if (phoneMonitor.supported & PM_EXTPBK)
+    if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT)
     {
     }
     else
@@ -538,7 +511,7 @@ because you save it into SIM memory!"));
       gtk_widget_show (errorDialog.dialog);
     }
 
-    if (phoneMonitor.supported & PM_EXTPBK)
+    if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT)
     {
     }
     else
@@ -564,7 +537,7 @@ because you save it into SIM memory!"));
               max_phonebook_name_length);
       ((EditEntryData*) data)->pbEntry->entry.Name[max_phonebook_name_length] = '\0';
 
-      if (phoneMonitor.supported & PM_EXTPBK)
+      if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT)
       {
       }
       else
@@ -589,7 +562,7 @@ because you save it into SIM memory!"));
         gtk_widget_show (errorDialog.dialog);
       }
 
-      if (phoneMonitor.supported & PM_EXTPBK)
+      if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT)
       {
       }
       else
@@ -632,7 +605,7 @@ because you save it into SIM memory!"));
     clist_row[2] = "P";
   else
     clist_row[2] = "S";
-  if (phoneMonitor.supported & PM_CALLERGROUP)
+  if (GetModelFeature(FN_CALLERGROUPS)!=0)
     clist_row[3] = xgnokiiConfig.callerGroups[((EditEntryData*) data)->pbEntry->entry.Group];
   else
     clist_row[3] = "";
@@ -731,7 +704,7 @@ static void OkChangeEntryDialog( GtkWidget *widget, gpointer data)
       clist_row[2] = "P";
     else
       clist_row[2] = "S";
-    if (phoneMonitor.supported & PM_CALLERGROUP)
+    if (GetModelFeature(FN_CALLERGROUPS)!=0)
       clist_row[3] = xgnokiiConfig.callerGroups[newPbEntry->entry.Group];
     else
       clist_row[3] = "";
@@ -1104,7 +1077,7 @@ static void CreateEditDialog (EditEntryData *editEntryData, gchar *title,
   gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
   gtk_widget_show (label);
 
-  if (phoneMonitor.supported & PM_EXTPBK)
+  if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT)
   {
     button = gtk_button_new ();
     editEntryData->number = gtk_label_new ("");
@@ -1124,7 +1097,7 @@ static void CreateEditDialog (EditEntryData *editEntryData, gchar *title,
     gtk_widget_show (editEntryData->number);
   }
 
-/*  if (phoneMonitor.supported & PM_EXTPBK) {
+/*  if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) {
 
     hbox = gtk_hbox_new (FALSE, 0);
     gtk_container_add (GTK_CONTAINER (GTK_DIALOG (editEntryData->dialog)->vbox), hbox);
@@ -1187,7 +1160,7 @@ static void EditPbEntry(PhonebookEntry *pbEntry, gint row)
 
   gtk_entry_set_text (GTK_ENTRY (editEditEntryData.name), pbEntry->entry.Name);
 
-  if (phoneMonitor.supported & PM_EXTPBK)
+  if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT)
     gtk_label_set_text (GTK_LABEL (editEditEntryData.number), pbEntry->entry.Number);
   else
     gtk_entry_set_text (GTK_ENTRY (editEditEntryData.number), pbEntry->entry.Number);
@@ -1200,7 +1173,7 @@ static void EditPbEntry(PhonebookEntry *pbEntry, gint row)
   gtk_option_menu_set_history( GTK_OPTION_MENU (editEditEntryData.group),
                                pbEntry->entry.Group);
 
-  if (phoneMonitor.supported & PM_CALLERGROUP)
+  if (GetModelFeature(FN_CALLERGROUPS)!=0)
   {
     gtk_widget_show (editEditEntryData.group);
     gtk_widget_show (editEditEntryData.groupLabel);
@@ -1280,7 +1253,7 @@ void NewPbEntry(PhonebookEntry *pbEntry)
 
   gtk_entry_set_text (GTK_ENTRY (newEditEntryData.name), "");
   
-  if (phoneMonitor.supported & PM_EXTPBK)
+  if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT)
     gtk_label_set_text (GTK_LABEL (newEditEntryData.number), "");
   else
     gtk_entry_set_text (GTK_ENTRY (newEditEntryData.number), "");
@@ -1293,7 +1266,7 @@ void NewPbEntry(PhonebookEntry *pbEntry)
   gtk_option_menu_set_history( GTK_OPTION_MENU (newEditEntryData.group),
                                pbEntry->entry.Group);
 
-  if (phoneMonitor.supported & PM_CALLERGROUP)
+  if (GetModelFeature(FN_CALLERGROUPS)!=0)
   {
     gtk_widget_show (newEditEntryData.group);
     gtk_widget_show (newEditEntryData.groupLabel);
@@ -1324,7 +1297,7 @@ void DuplicatePbEntry (PhonebookEntry *pbEntry)
 
   gtk_entry_set_text (GTK_ENTRY (duplicateEditEntryData.name), pbEntry->entry.Name);
 
-  if (phoneMonitor.supported & PM_EXTPBK)
+  if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT)
     gtk_label_set_text (GTK_LABEL (duplicateEditEntryData.number), pbEntry->entry.Number);
   else
     gtk_entry_set_text (GTK_ENTRY (duplicateEditEntryData.number), pbEntry->entry.Number);
@@ -1337,7 +1310,7 @@ void DuplicatePbEntry (PhonebookEntry *pbEntry)
   gtk_option_menu_set_history( GTK_OPTION_MENU (duplicateEditEntryData.group),
                                pbEntry->entry.Group);
 
-  if (phoneMonitor.supported & PM_CALLERGROUP)
+  if (GetModelFeature(FN_CALLERGROUPS)!=0)
   {
     gtk_widget_show (duplicateEditEntryData.group);
     gtk_widget_show (duplicateEditEntryData.groupLabel);
@@ -2057,7 +2030,7 @@ void GUI_RefreshContacts (void)
         row[2] = "P";
       else
         row[2] = "S";
-      if (phoneMonitor.supported & PM_CALLERGROUP)
+      if (GetModelFeature(FN_CALLERGROUPS)!=0)
         row[3] = xgnokiiConfig.callerGroups[pbEntry->entry.Group];
       else
         row[3] = "";
@@ -2247,6 +2220,7 @@ Setting max SIM entries to 100!\n"));
     mla->min = 1;
     mla->max = memoryStatus.MaxME;
     mla->type = GMT_ME;
+    mla->used = memoryStatus.UsedME; //MW
     mla->InsertEntry = InsertPBEntryME;
     mla->ReadFailed = ReadFailedPBEntry;
 
@@ -2269,6 +2243,7 @@ Setting max SIM entries to 100!\n"));
   mla->min = 1;
   mla->max = memoryStatus.MaxSM;
   mla->type = GMT_SM;
+  mla->used = memoryStatus.UsedSM; //MW
   mla->InsertEntry = InsertPBEntrySM;
   mla->ReadFailed = ReadFailedPBEntry;
 
@@ -2352,7 +2327,7 @@ inline void GUI_ShowContacts (void)
     GUI_Refresh ();
     GUI_InitCallerGroupsInf ();
   }
-  gtk_clist_set_column_visibility (GTK_CLIST (clist), 3, phoneMonitor.supported & PM_CALLERGROUP);
+  gtk_clist_set_column_visibility (GTK_CLIST (clist), 3, (GetModelFeature(FN_CALLERGROUPS)!=0));
   GUI_RefreshContacts ();
   gtk_widget_show (GUI_ContactsWindow);
 //  if (!contactsMemoryInitialized)
@@ -2386,7 +2361,7 @@ static void ExportVCARD (FILE *f)
     fprintf (f, "X_GSM_CALLERGROUP:%d\n", pbEntry->entry.Group);
 
     /* Add ext. pbk info if required */
-    if (phoneMonitor.supported & PM_EXTPBK)
+    if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT)
       for (j = 0; j < pbEntry->entry.SubEntriesCount; j++)
       {
        if (pbEntry->entry.SubEntries[j].EntryType == GSM_Number)
@@ -2445,7 +2420,7 @@ static void ExportNative (FILE *f)
       strcat (buf, buf2);
 
       /* Add ext. pbk info if required */
-      if (phoneMonitor.supported & PM_EXTPBK)
+      if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT)
       {
         for (j = 0; j < pbEntry->entry.SubEntriesCount; j++)
           if (pbEntry->entry.SubEntries[j].EntryType==GSM_Number)
@@ -3145,7 +3120,7 @@ SelectContactData *GUI_SelectContactDialog (void)
   gtk_clist_set_column_width (GTK_CLIST(selectContactData.clist), 1, 115);
   gtk_clist_set_column_width (GTK_CLIST(selectContactData.clist), 3, 70);
   gtk_clist_set_column_justification (GTK_CLIST(selectContactData.clist), 2, GTK_JUSTIFY_CENTER);
-  gtk_clist_set_column_visibility (GTK_CLIST(selectContactData.clist), 3, phoneMonitor.supported & PM_CALLERGROUP);
+  gtk_clist_set_column_visibility (GTK_CLIST(selectContactData.clist), 3, (GetModelFeature(FN_CALLERGROUPS)!=0));
 
   for (i = 0; i < 4; i++)
   {
@@ -3199,7 +3174,7 @@ SelectContactData *GUI_SelectContactDialog (void)
         row[2] = "P";
       else
         row[2] = "S";
-      if (phoneMonitor.supported & PM_CALLERGROUP)
+      if (GetModelFeature(FN_CALLERGROUPS)!=0)
         row[3] = xgnokiiConfig.callerGroups[pbEntry->entry.Group];
       else
         row[3] = "";
@@ -3300,7 +3275,6 @@ void GUI_CreateContactsWindow (void)
   InitMainMenu ();
   contactsMemoryInitialized = FALSE;
   GUI_ContactsWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  gtk_window_set_wmclass (GTK_WINDOW (GUI_ContactsWindow), "ContactsWindow", "Xgnokii");
   gtk_window_set_title (GTK_WINDOW (GUI_ContactsWindow), _("Contacts"));
   gtk_widget_set_usize (GTK_WIDGET (GUI_ContactsWindow), 436, 220);
   //gtk_container_set_border_width (GTK_CONTAINER (GUI_ContactsWindow), 10);
@@ -3396,7 +3370,7 @@ void GUI_CreateContactsWindow (void)
   gtk_clist_set_column_width (GTK_CLIST (clist), 1, 115);
   gtk_clist_set_column_width (GTK_CLIST (clist), 3, 70);
   gtk_clist_set_column_justification (GTK_CLIST (clist), 2, GTK_JUSTIFY_CENTER);
-//  gtk_clist_set_column_visibility (GTK_CLIST (clist), 3, phoneMonitor.supported & PM_CALLERGROUP);
+//  gtk_clist_set_column_visibility (GTK_CLIST (clist), 3, (GetModelFeature(FN_CALLERGROUPS)!=0));
 
   for (i = 0; i < 4; i++)
   {