http://marcin-wiacek.fkn.pl/english/zips/mygnokii.tar.gz
[gnokii.git] / xgnokii / xgnokii_contacts.h
1 /*
2
3   X G N O K I I
4
5   A Linux/Unix GUI for Nokia mobile phones.
6
7   Released under the terms of the GNU GPL, see file COPYING for more details.
8
9   $Id$
10   
11 */
12
13 #ifndef XGNOKII_CONTACTS_H
14 #define XGNOKII_CONTACTS_H
15
16 #include <gtk/gtk.h>
17 #include "misc.h"
18 #include "gsm-common.h"
19 #include "gsm-api.h"
20
21 #define IO_BUF_LEN      160
22
23 /* Structure to keep memory status information */
24 typedef struct {
25   int MaxME;            /* Maximum Phone memory entries. */
26   int UsedME;           /* Actualy used Phone memory entries. */
27   int FreeME;           /* FreeME = MaxME - UsedME */
28   int MaxSM;            /* Maximum SIM memory entries. */
29   int UsedSM;
30   int FreeSM;
31 } MemoryStatus;
32
33 /* Array to hold contacts entry */
34 typedef GPtrArray* ContactsMemory;
35
36 /* Structure to keep contacts memory entry status */
37 typedef enum {
38   E_Unchanged,          /* Entry is not empty and is unchanged. */
39   E_Changed,            /* Entry is not empty and is changed. */
40   E_Deleted,            /* Entry was deleted. */
41   E_Empty               /* Entry is empty. */
42 } EntryStatus;
43
44 /* Memory entry data */
45 typedef struct {
46   GSM_PhonebookEntry entry;     /* Phonebook entry self. */
47   EntryStatus status;           /* Entry status. */
48 } PhonebookEntry;
49
50 /* Structure to hold information of Edit and New dialogs */
51 typedef struct {
52   PhonebookEntry *pbEntry;
53   GtkWidget *dialog;
54   GtkWidget *name;
55   GtkWidget *number;
56   GtkWidget *extended;
57   GtkWidget *memoryBox;
58   GtkWidget *memoryTypePhone;
59   GtkWidget *memoryTypeSIM;
60   GtkWidget *group;
61   GtkWidget *groupLabel;
62   GtkWidget *groupMenu;
63   gint      newGroup;
64   gint      row;
65 } EditEntryData;
66
67
68 typedef struct {
69   PhonebookEntry *pbEntry;
70   GtkWidget *dialog;
71   GtkWidget *clist;
72 } EditNumbersData;
73
74
75 /* Structure to hold information for FindEntry dialog. */
76 typedef struct {
77   GtkWidget *dialog;
78   GtkWidget *pattern;
79   GtkWidget *nameB;
80   GtkWidget *numberB;
81 } FindEntryData;
82
83
84 /* Contains fileName for Export dialog. */
85 typedef struct {
86   gchar *fileName;
87 } ExportDialogData;
88
89
90 /* Hold widgets for SelectContactDialog */
91 typedef struct {
92   GtkWidget *dialog;
93   GtkWidget *clist;                     /* list of contacts */
94   GtkWidget *clistScrolledWindow;
95   GtkWidget *okButton;                  /* Ok and Cancel button widgets */
96   GtkWidget *cancelButton;
97 } SelectContactData;
98
99
100 /* Max length for status line. (Line that shows used/max information for
101    memories). */
102 #define STATUS_INFO_LENGTH      40
103
104
105 /* Structure to hold information for status line (bottom line of window) */
106 typedef struct {
107   GtkWidget *label;
108   gchar text[STATUS_INFO_LENGTH];       /* Status line text. */
109   gint ch_ME:1;                         /* 1 if phone memory was changed */
110   gint ch_SM:1;                         /* 1 if phone SIM was changed */
111 } StatusInfo;
112
113
114 /* Structure to hold information for progress dialog */
115 typedef struct {
116   GtkWidget *dialog;
117   GtkWidget *pbarME;
118   GtkWidget *pbarSM;
119 } ProgressDialog;
120
121
122 /* Search type. */
123 typedef enum {
124   FIND_NAME = 0,
125   FIND_NUMBER
126 } FindType;
127
128
129 typedef struct {
130   gchar pattern[GSM_MAX_PHONEBOOK_NAME_LENGTH + 1];
131   gint lastRow;
132   FindType type;
133 } FindEntryStruct;
134
135
136 typedef struct {
137   GdkPixmap *simMemPix, *phoneMemPix;
138   GdkBitmap *mask;
139 } MemoryPixmaps;
140
141
142 extern void GUI_CreateContactsWindow (void);
143
144 extern void GUI_ShowContacts (void);
145
146 /* return != 0 if user has unsaved changes in contacts memory */ 
147 extern gint GUI_ContactsIsChanged (void);
148
149 /* return TRUE if Contacts memory was read from phone or from file */
150 extern bool GUI_ContactsIsIntialized (void);
151
152 /* Read contacts from phone */
153 extern void GUI_ReadContacts (void);
154
155 /* Save contacts to phone */
156 extern void GUI_SaveContacts (void);
157
158 /* Create save question dialog and can end application */
159 extern void GUI_QuitSaveContacts (void);
160
161 extern void GUI_RefreshContacts (void);
162
163 /* Function take number and return name belonged to number.
164    If no name is found, return NULL;
165    Do not modify returned name!                                 */
166 extern gchar *GUI_GetName (gchar *number);
167
168 extern gchar *GUI_GetNameExact (gchar *number);
169
170 extern gchar *GUI_GetNumber (gchar *name);
171 /* Function show dialog with contacts and let select entries.
172    See xgnokii_contacts.c for sample of use.                    */
173 extern SelectContactData *GUI_SelectContactDialog (void);
174
175 extern void GUI_RefreshGroupMenu (void);
176
177 extern PhonebookEntry *GUI_GetEntry (GSM_MemoryType, gint);
178
179 void ExtPbkChanged (GtkWidget *widget, gpointer data );
180
181 #endif