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