1 /*
2 
3   $Id$
4 
5   X G N O K I I
6 
7   A Linux/Unix GUI for the mobile phones.
8 
9   This file is part of gnokii.
10 
11   Gnokii is free software; you can redistribute it and/or modify
12   it under the terms of the GNU General Public License as published by
13   the Free Software Foundation; either version 2 of the License, or
14   (at your option) any later version.
15 
16   Gnokii is distributed in the hope that it will be useful,
17   but WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   GNU General Public License for more details.
20 
21   You should have received a copy of the GNU General Public License
22   along with gnokii; if not, write to the Free Software
23   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24 
25   Copyright (C) 1999 Pavel Jan�k ml., Hugh Blemings
26   Copyright (C) 1999-2005 Jan Derfinak.
27   Copyright (C) 2001-2003 Pawel Kot
28   Copyright (C) 2002      BORBELY Zoltan, Markus Plail
29 
30 */
31 
32 #ifndef XGNOKII_CONTACTS_H
33 #define XGNOKII_CONTACTS_H
34 
35 #include <gtk/gtk.h>
36 #include "misc.h"
37 #include "gnokii.h"
38 
39 #define IO_BUF_LEN	1024
40 
41 /* Structure to keep memory status information */
42 typedef struct {
43 	int MaxME;		/* Maximum Phone memory entries. */
44 	int UsedME;		/* Actualy used Phone memory entries. */
45 	int FreeME;		/* FreeME = MaxME - UsedME */
46 	int MaxSM;		/* Maximum SIM memory entries. */
47 	int UsedSM;
48 	int FreeSM;
49 } MemoryStatus;
50 
51 /* Array to hold contacts entry */
52 typedef GPtrArray *ContactsMemory;
53 
54 /* Structure to keep contacts memory entry status */
55 typedef enum {
56 	E_Unchanged,		/* Entry is not empty and is unchanged. */
57 	E_Changed,		/* Entry is not empty and is changed. */
58 	E_Deleted,		/* Entry was deleted. */
59 	E_Empty			/* Entry is empty. */
60 } EntryStatus;
61 
62 /* Memory entry data */
63 typedef struct {
64 	gn_phonebook_entry entry;	/* Phonebook entry self. */
65 	EntryStatus status;	/* Entry status. */
66 } PhonebookEntry;
67 
68 /* Structure to hold information of Edit and New dialogs */
69 typedef struct {
70 	PhonebookEntry *pbEntry;
71 	GtkWidget *dialog;
72 	GtkWidget *name;
73 	GtkWidget *number;
74 	GtkWidget *extended;
75 	GtkWidget *memoryBox;
76 	GtkWidget *memoryTypePhone;
77 	GtkWidget *memoryTypeSIM;
78 	GtkWidget *group;
79 	GtkWidget *groupLabel;
80 	GtkWidget *groupMenu;
81 	gint newGroup;
82 	gint newType;
83 	gint row;
84 } EditEntryData;
85 
86 
87 typedef struct {
88 	PhonebookEntry *pbEntry;
89 	GtkWidget *dialog;
90 	GtkWidget *clist;
91 	gint row;
92 } EditNumbersData;
93 
94 
95 /* Structure to hold information for FindEntry dialog. */
96 typedef struct {
97 	GtkWidget *dialog;
98 	GtkWidget *pattern;
99 	GtkWidget *nameB;
100 	GtkWidget *numberB;
101 } FindEntryData;
102 
103 
104 /* Contains fileName for Export dialog. */
105 typedef struct {
106 	gchar *fileName;
107 } ExportDialogData;
108 
109 
110 /* Hold widgets for SelectContactDialog */
111 typedef struct {
112 	GtkWidget *dialog;
113 	GtkWidget *clist;	/* list of contacts */
114 	GtkWidget *clistScrolledWindow;
115 	GtkWidget *okButton;	/* Ok and Cancel button widgets */
116 	GtkWidget *cancelButton;
117 } SelectContactData;
118 
119 
120 /* Max length for status line. (Line that shows used/max information for
121    memories). */
122 #define STATUS_INFO_LENGTH	40
123 
124 
125 /* Structure to hold information for status line (bottom line of window) */
126 typedef struct {
127 	GtkWidget *label;
128 	gchar text[STATUS_INFO_LENGTH];	/* Status line text. */
129 	gint ch_ME:1;		/* 1 if phone memory was changed */
130 	gint ch_SM:1;		/* 1 if phone SIM was changed */
131 } StatusInfo;
132 
133 
134 /* Structure to hold information for progress dialog */
135 typedef struct {
136 	GtkWidget *dialog;
137 	GtkWidget *pbarME;
138 	GtkWidget *pbarSM;
139 } ProgressDialog;
140 
141 
142 /* Search type. */
143 typedef enum {
144 	FIND_NAME = 0,
145 	FIND_NUMBER
146 } FindType;
147 
148 
149 typedef struct {
150 	gchar pattern[GN_PHONEBOOK_NAME_MAX_LENGTH + 1];
151 	gint lastRow;
152 	FindType type;
153 } FindEntryStruct;
154 
155 
156 typedef struct {
157 	GdkPixmap *simMemPix, *phoneMemPix;
158 	GdkBitmap *mask;
159 } MemoryPixmaps;
160 
161 
162 extern void GUI_CreateContactsWindow(void);
163 
164 extern void GUI_ShowContacts(void);
165 
166 /* return != 0 if user has unsaved changes in contacts memory */
167 extern gint GUI_ContactsIsChanged(void);
168 
169 /* return TRUE if Contacts memory was read from phone or from file */
170 extern bool GUI_ContactsIsIntialized(void);
171 
172 /* Read contacts from phone */
173 extern void GUI_ReadContacts(void);
174 
175 /* Save contacts to phone */
176 extern void GUI_SaveContacts(void);
177 
178 /* Create save question dialog and can end application */
179 extern void GUI_QuitSaveContacts(void);
180 
181 extern void GUI_RefreshContacts(void);
182 
183 /* Function take number and return name belonged to number.
184    If no name is found, return NULL;
185    Do not modify returned name!					*/
186 extern gchar *GUI_GetName(gchar * number);
187 
188 extern gchar *GUI_GetNameExact(gchar * number);
189 
190 extern gchar *GUI_GetNumber(gchar * name);
191 /* Function show dialog with contacts and let select entries.
192    See xgnokii_contacts.c for sample of use.			*/
193 extern SelectContactData *GUI_SelectContactDialog(void);
194 
195 extern void GUI_RefreshGroupMenu(void);
196 
197 extern PhonebookEntry *GUI_GetEntry(gn_memory_type, gint);
198 
199 void ExtPbkChanged(GtkWidget * widget, gpointer data);
200 
201 #endif
202