Translation update done using Pootle.
[gammu.git] / tests / sms-nokia-16.c
blob46ac8fff8dda65e9a4864c0b337f55f911203480
1 /* Test for decoding SMS on Nokia 6510 driver */
3 #include <gammu.h>
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <string.h>
8 #include "common.h"
10 #include "../libgammu/protocol/protocol.h" /* Needed for GSM_Protocol_Message */
11 #include "../libgammu/gsmstate.h" /* Needed for state machine internals */
13 #include "../helper/message-display.h"
15 unsigned char data[] = {
16 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x01, 0xE6, 0x00, 0x00, 0x00, 0x00,
17 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B,
22 0x00, 0x33, 0x00, 0x32, 0x00, 0x34, 0x00, 0x38, 0x00, 0x34, 0x00, 0x30, 0x00, 0x35, 0x00, 0x33,
23 0x00, 0x30, 0x00, 0x38, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27 0x11, 0x00, 0x14, 0x91, 0x53, 0x58, 0x76, 0x98, 0x21, 0x43, 0x65, 0x87, 0x19, 0x32, 0x00, 0x00,
28 0xFF, 0x4B, 0x41, 0x36, 0xFB, 0x2D, 0x0F, 0xB3, 0x40, 0xE3, 0x34, 0x68, 0x9E, 0x2E, 0xD3, 0xCB,
29 0xBF, 0x10, 0xC8, 0x5A, 0x26, 0xA7, 0xC3, 0xED, 0xF7, 0x38, 0x1D, 0x02, 0x11, 0xDF, 0xED, 0xB0,
30 0x3B, 0xFD, 0x03, 0x25, 0xDF, 0xA0, 0x78, 0xBD, 0x3C, 0xA7, 0xBF, 0x41, 0xF7, 0x72, 0x79, 0x0D,
31 0x2A, 0xBB, 0xC9, 0x20, 0x73, 0xFD, 0x2D, 0x4F, 0x83, 0xC4, 0x78, 0xB6, 0x0B, 0x14, 0x04, 0xC1,
32 0xD9, 0xF5, 0x79, 0x08, 0x01, 0x00, 0xDF, 0x01, 0x00, 0x01, 0x01, 0x03, 0x00, 0x98, 0x00, 0x41,
33 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x61, 0x00, 0x2C, 0x00, 0x20, 0x00, 0x63,
34 0x00, 0x69, 0x00, 0x20, 0x00, 0x73, 0x00, 0x69, 0x00, 0x65, 0x00, 0x74, 0x00, 0x65, 0x00, 0x3F,
35 0x00, 0x21, 0x00, 0x20, 0x00, 0x56, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x61, 0x00, 0x6D,
36 0x00, 0x6F, 0x00, 0x63, 0x00, 0x69, 0x00, 0x21, 0x00, 0x20, 0x00, 0x44, 0x00, 0x6F, 0x00, 0x6D,
37 0x00, 0x61, 0x00, 0x6E, 0x00, 0x69, 0x00, 0x3F, 0x00, 0x20, 0x00, 0x49, 0x00, 0x6F, 0x00, 0x20,
38 0x00, 0x71, 0x00, 0x75, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x20, 0x00, 0x77,
39 0x00, 0x65, 0x00, 0x65, 0x00, 0x6B, 0x00, 0x20, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x20,
40 0x00, 0x66, 0x00, 0x75, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x69, 0x00, 0x20, 0x00, 0x62, 0x00, 0x78,
41 0x00, 0x6C, 0x00, 0x2E, 0x00, 0x20, 0x00, 0x41, 0x00, 0x20, 0x00, 0x70, 0x00, 0x6C, 0x00, 0x75,
42 0x00, 0x73, 0x00, 0x21, 0x00, 0x00, 0x04, 0x00, 0x1A, 0x00, 0x2B, 0x00, 0x33, 0x00, 0x32, 0x00,
43 0x34, 0x00, 0x38, 0x00, 0x34, 0x00, 0x30, 0x00, 0x35, 0x00, 0x33, 0x00, 0x30, 0x00, 0x38, 0x00,
44 0x38, 0x00, 0x00, 0x0C, 0x00, 0x02, 0x31, 0x00, 0x07, 0x00, 0x01, 0x0E, 0x05, 0x00, 0x01, 0x02,
45 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x0B, 0x00, 0x01, 0x00, 0x09,
46 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00
49 const char text[] = "Allora, ci siete?! Vediamoci! Domani? Io questo week end fuori bxl. A plus!";
50 char decoded_text[200];
52 /* This is not part of API! */
53 extern GSM_Error N6510_DecodeFilesystemSMS(GSM_StateMachine * s, GSM_MultiSMSMessage * sms, GSM_File * FFF, int location);
55 int main(int argc UNUSED, char **argv UNUSED)
57 GSM_Debug_Info *debug_info;
58 GSM_StateMachine *s;
59 GSM_File file;
60 GSM_Error error;
61 GSM_MultiSMSMessage sms;
63 /* Init locales for proper output */
64 GSM_InitLocales(NULL);
66 debug_info = GSM_GetGlobalDebug();
67 GSM_SetDebugFileDescriptor(stderr, FALSE, debug_info);
68 GSM_SetDebugLevel("textall", debug_info);
70 /* Allocates state machine */
71 s = GSM_AllocStateMachine();
72 test_result(s != NULL);
74 debug_info = GSM_GetDebug(s);
75 GSM_SetDebugGlobal(TRUE, debug_info);
77 /* Init file */
78 file.Buffer = malloc(sizeof(data));
79 memcpy(file.Buffer, data, sizeof(data));
80 file.Used = sizeof(data);
81 file.ID_FullName[0] = 0;
82 file.ID_FullName[1] = 0;
83 GSM_GetCurrentDateTime(&(file.Modified));
85 /* Parse it */
86 error = N6510_DecodeFilesystemSMS(s, &sms, &file, 0);
88 /* Display message */
89 DisplayMultiSMSInfo(&sms, FALSE, TRUE, NULL, NULL);
90 DisplayMultiSMSInfo(&sms, TRUE, TRUE, NULL, NULL);
92 /* Free state machine */
93 GSM_FreeStateMachine(s);
95 /* Check expected text */
96 /* We do not compare full text due to locales problem */
97 EncodeUTF8(decoded_text, sms.SMS[0].Text);
98 test_result(strcmp(text, decoded_text) == 0);
100 gammu_test_result(error, "N6510_DecodeFilesystemSMS");
102 return 0;
105 /* Editor configuration
106 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: