summaryrefslogtreecommitdiff
path: root/include/gammu-file.h
blob: be4db63b87b5f01a8938a030487fa2a293b3e249 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
/**
 * \file gammu-file.h
 * \author Michal Čihař
 *
 * File manipulations.
 */
#ifndef __gammu_file_h
#define __gammu_file_h

/**
 * \defgroup File File
 * Files handling.
 */

#ifdef	__cplusplus
extern "C" {
#endif

#include <gammu-types.h>
#include <gammu-datetime.h>
#include <gammu-limits.h>

/**
 * Status of filesystem.
 *
 * \ingroup File
 */
typedef struct {
	int Free;
	int Used;
	int UsedImages;
	int UsedSounds;
	int UsedThemes;
} GSM_FileSystemStatus;

/**
 * File type identifier.
 *
 * \ingroup File
 */
typedef enum {
	GSM_File_Other = 1,
	GSM_File_Java_JAR,
	GSM_File_Image_JPG,
	GSM_File_Image_BMP,
	GSM_File_Image_GIF,
	GSM_File_Image_PNG,
	GSM_File_Image_WBMP,
	GSM_File_Video_3GP,
	GSM_File_Sound_AMR,
	/**
	 * DCT4 binary format
	 */
	GSM_File_Sound_NRT,
	GSM_File_Sound_MIDI,
	GSM_File_MMS,

	GSM_File_INVALID
} GSM_FileType;

/**
 * Structure for holding file information and data.
 *
 * \ingroup File
 */
typedef struct {
	/**
	 * How many bytes are used.
	 */
	size_t Used;
	/**
	 * Name in Unicode
	 */
	unsigned char Name[2 * (GSM_MAX_FILENAME_LENGTH + 1)];
	/**
	 * True, when folder
	 */
	gboolean Folder;
	/**
	 * How much file is nested on filesystem.
	 */
	int Level;
	/**
	 * Type of file.
	 */
	GSM_FileType Type;
	/**
	 * ID in Unicode
	 */
	unsigned char ID_FullName[2 * (GSM_MAX_FILENAME_ID_LENGTH + 1)];
	/**
	 * Pointer to file data.
	 */
	unsigned char *Buffer;
	/**
	 * Last modification date.
	 */
	GSM_DateTime Modified;
	/**
	 * Whether modification date is empty.
	 */
	gboolean ModifiedEmpty;

	/**
	 * Protected file attribute.
	 */
	gboolean Protected;
	/**
	 * Read only file attribute.
	 */
	gboolean ReadOnly;
	/**
	 * Hidden file attribute.
	 */
	gboolean Hidden;
	/**
	 * System file attribute.
	 */
	gboolean System;
} GSM_File;

/**
 * Parses JAD file.
 *
 * \param File JAD file data.
 * \param Vendor Buffer for vendor name.
 * \param Name Buffer for application name.
 * \param JAR Buffer for JAR URL.
 * \param Version Buffer for version of application.
 * \param Size Pointer to integer to store size.
 *
 * \return Error code.
 *
 * \ingroup File
 */
GSM_Error GSM_JADFindData(GSM_File *File, char *Vendor, char *Name, char *JAR,
			  char *Version, int *Size);

/**
 * Reads file from filesystem to \ref GSM_File structure.
 *
 * \param FileName File to read.
 * \param File Storage for data.
 *
 * \return Error code.
 *
 * \ingroup File
 */
GSM_Error GSM_ReadFile(const char *FileName, GSM_File * File);

/**
 * Identifies file format by checking it's content.
 *
 * \param File File data, Type member will be filled in.
 *
 * \ingroup File
 */
void GSM_IdentifyFileFormat(GSM_File * File);

/**
 * Gets next filename from filesystem.
 *
 * \param s State machine pointer.
 * \param File File structure where path will be stored, if start is
 * FALSE, it should contain data from previous reading (at least ID).
 * \param start Whether we're starting transfer.
 *
 * \return Error code.
 *
 * \ingroup File
 */
GSM_Error GSM_GetNextFileFolder(GSM_StateMachine * s, GSM_File * File,
				gboolean start);
/**
 * Gets listing of folder.
 *
 * \param s State machine pointer.
 * \param File File structure where path will be stored, if start is
 * FALSE, it should contain data from previous reading (at least ID). On
 * start it should contain path to directory.
 * \param start Whether we're starting transfer.
 *
 * \return Error code.
 *
 * \ingroup File
 */
GSM_Error GSM_GetFolderListing(GSM_StateMachine * s, GSM_File * File,
			       gboolean start);
/**
 * Gets next root folder.
 *
 * \param s State machine pointer.
 * \param File File structure where path will be stored.
 *
 * \return Error code.
 *
 * \ingroup File
 */
GSM_Error GSM_GetNextRootFolder(GSM_StateMachine * s, GSM_File * File);

/**
 * Sets file system attributes.
 *
 * \param s State machine pointer.
 * \param File File structure with path and attributes.
 *
 * \return Error code.
 *
 * \ingroup File
 */
GSM_Error GSM_SetFileAttributes(GSM_StateMachine * s, GSM_File * File);

/**
 * Retrieves file part.
 *
 * \param s State machine pointer.
 * \param File File structure with path, data will be stored here.
 * \param Size Size of transmitted data.
 * \param Handle Handle for saving file, some drivers need this
 * information to be kept between function calls.
 *
 * \return Error code, \ref ERR_EMPTY after transfer end.
 *
 * \ingroup File
 */
GSM_Error GSM_GetFilePart(GSM_StateMachine * s, GSM_File * File, int *Handle,
			  int *Size);

/**
 * Adds file to filesystem. Call repeatedly until function returns
 * \ref ERR_EMPTY.
 *
 * \param s State machine pointer.
 * \param File File structure and data.
 * \param Pos Position of transmitted data. Should be 0 on start.
 * \param Handle Handle for saving file, some drivers need this
 * information to be kept between function calls.
 *
 * \return Error code, \ref ERR_EMPTY after transfer end.
 *
 * \ingroup File
 */
GSM_Error GSM_AddFilePart(GSM_StateMachine * s, GSM_File * File, int *Pos,
			  int *Handle);
/**
 * Sends file to phone, it's up to phone to decide what to do with it.
 * It is usually same as when you receive file over Bluetooth from other
 * phone. Use in same way as \ref GSM_AddFilePart.
 *
 * \param s State machine pointer.
 * \param File File structure and data.
 * \param Pos Position of transmitted data. Should be 0 on start.
 * \param Handle Handle for saving file, some drivers need this
 * information to be kept between function calls.
 *
 * \return Error code, \ref ERR_EMPTY after transfer end.
 *
 * \ingroup File
 */
GSM_Error GSM_SendFilePart(GSM_StateMachine * s, GSM_File * File, int *Pos,
			   int *Handle);
/**
 * Acquires filesystem status.
 *
 * \param s State machine pointer.
 * \param Status Storage for status information.
 *
 * \return Error code.
 *
 * \ingroup File
 */
GSM_Error GSM_GetFileSystemStatus(GSM_StateMachine * s,
				  GSM_FileSystemStatus * Status);
/**
 * Deletes file from filesystem.
 *
 * \param s State machine pointer.
 * \param ID ID of folder.
 *
 * \return Error code.
 *
 * \ingroup File
 */
GSM_Error GSM_DeleteFile(GSM_StateMachine * s, unsigned char *ID);

/**
 * Adds folder to filesystem.
 *
 * \param s State machine pointer.
 * \param File Structure containing information about new folder (Name
 * and FullName).
 *
 * \return Error code.
 *
 * \ingroup File
 */
GSM_Error GSM_AddFolder(GSM_StateMachine * s, GSM_File * File);

/**
 * Deletes folder from filesystem.
 *
 * \param s State machine pointer.
 * \param ID ID of folder.
 *
 * \return Error code.
 *
 * \ingroup File
 */
GSM_Error GSM_DeleteFolder(GSM_StateMachine * s, unsigned char *ID);
#ifdef	__cplusplus
}
#endif
#endif

/* Editor configuration
 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72:
 */