[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fix EMS + concat message, cleanup gnokii.c
From: |
Pavel Machek |
Subject: |
Fix EMS + concat message, cleanup gnokii.c |
Date: |
Fri, 7 Jun 2002 11:57:09 +0200 |
User-agent: |
Mutt/1.3.28i |
Hi!
This fixes concatenated message header in combination with other
headers.
In gnokii.c it fixes concat+animation case and moves sending ems
pictures to --sendsms, so sendlogo can be killed in future.
If there are no big complains, I'll commit.
Pavel
Index: common/gsm-bitmaps.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-bitmaps.c,v
retrieving revision 1.29
diff -u -u -r1.29 gsm-bitmaps.c
--- common/gsm-bitmaps.c 3 Jun 2002 22:59:48 -0000 1.29
+++ common/gsm-bitmaps.c 7 Jun 2002 09:51:26 -0000
@@ -220,7 +220,7 @@
/* Returns message length */
-int GSM_EncodeSMSBitmap(GSM_Bitmap *bitmap, char *message)
+int GSM_EncodeSMSBitmap(GSM_SMSMessage *rawsms, GSM_Bitmap *bitmap, char
*message)
{
unsigned short size, current = 0;
int i;
@@ -260,7 +267,7 @@
fprintf(stderr, "EMS needs bitmap size 8, 16, 24, ...
\n");
return GE_NOTSUPPORTED;
}
- message[current++] = bitmap->width/8*bitmap->height+5;
+ current += AddUDH(rawsms, bitmap->width/8*bitmap->height+5);
message[current++] = 0x12; /* Picture code */
message[current++] = bitmap->width/8*bitmap->height+3; /*
Picture size */;
message[current++] = 0; /* Position in text this
picture is at */
@@ -269,7 +276,7 @@
break;
case GSM_EMSAnimation:
dprintf("EMS animation\n");
- message[current++] = 128+3;
+ current += AddUDH(rawsms, 128+3);
message[current++] = 0x0e; /* Animation code */
message[current++] = 128+1; /* Picture size */;
message[current++] = 0x00; /* Position where to display */
Index: common/gsm-ringtones.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-ringtones.c,v
retrieving revision 1.11
diff -u -u -r1.11 gsm-ringtones.c
--- common/gsm-ringtones.c 23 May 2002 09:59:20 -0000 1.11
+++ common/gsm-ringtones.c 7 Jun 2002 09:51:30 -0000
@@ -586,12 +586,12 @@
}
/* Returns message length */
-int GSM_EncodeSMSiMelody(char *imelody, char *message)
+int GSM_EncodeSMSiMelody(GSM_SMSMessage *rawsms, char *imelody, char *message)
{
unsigned short size, current = 0;
dprintf("EMS iMelody\n");
- message[current++] = strlen(imelody)+3;
+ current += AddUDH(rawsms, strlen(imelody)+3);
message[current++] = 0x0c; /* iMelody code */
message[current++] = strlen(imelody)+1;
message[current++] = 0; /* Position in text this melody
is at */
Index: common/gsm-sms.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-sms.c,v
retrieving revision 1.92
diff -u -u -r1.92 gsm-sms.c
--- common/gsm-sms.c 4 Jun 2002 22:41:30 -0000 1.92
+++ common/gsm-sms.c 7 Jun 2002 09:51:40 -0000
@@ -951,6 +951,15 @@
*** ENCODING SMS
***/
+int AddUDH(GSM_SMSMessage *rawsms, int length)
+{
+ rawsms->UserData[0] += length;
+ if (!rawsms->UDHIndicator) {
+ rawsms->UDHIndicator = 1;
+ return 1;
+ }
+ return 0;
+}
/**
* EncodeUDH - encodes User Data Header
@@ -970,6 +979,7 @@
unsigned char pos;
char *UDH = rawsms->UserData;
char *res;
+ int length;
pos = UDH[0];
@@ -990,21 +1000,16 @@
case SMS_CallerIDLogo:
case SMS_Ringtone:
case SMS_MultipartMessage:
- UDH[0] += headers[type].length;
+ length = headers[type].length + AddUDH(rawsms,
headers[type].length);
res = UDH+pos+1;
memcpy(res, headers[type].header, headers[type].length);
- rawsms->UserDataLength += headers[type].length;
- rawsms->Length += headers[type].length;
+ rawsms->UserDataLength += length;
+ rawsms->Length += length;
break;
default:
dprintf("Not supported User Data Header type\n");
break;
}
- if (!rawsms->UDHIndicator) {
- rawsms->UDHIndicator = 1;
- rawsms->Length++; /* Length takes one byte, too */
- rawsms->UserDataLength++;
- }
return res;
}
@@ -1099,7 +1110,7 @@
case GSM_EMSPicture:
case GSM_EMSAnimation: break; /* We'll construct
headers in EncodeSMSBitmap */
}
- size =
GSM_EncodeSMSBitmap(&(sms->UserData[i].u.Bitmap), rawsms->UserData +
rawsms->UserDataLength);
+ size = GSM_EncodeSMSBitmap(rawsms,
&(sms->UserData[i].u.Bitmap), rawsms->UserData + rawsms->UserDataLength);
rawsms->Length += size;
rawsms->UserDataLength += size;
rawsms->DCS = 0xf5;
@@ -1110,7 +1121,7 @@
int j;
error = GE_NONE;
for (j=0; j<4; j++) {
- size =
GSM_EncodeSMSBitmap(&(sms->UserData[i].u.Animation[j]), rawsms->UserData +
rawsms->UserDataLength);
+ size = GSM_EncodeSMSBitmap(rawsms,
&(sms->UserData[i].u.Animation[j]), rawsms->UserData + rawsms->UserDataLength);
rawsms->Length += size;
rawsms->UserDataLength += size;
}
@@ -1155,7 +1166,7 @@
break;
case SMS_iMelodyText:
- size = GSM_EncodeSMSiMelody(sms->UserData[i].u.Text,
rawsms->UserData + rawsms->UserDataLength);
+ size = GSM_EncodeSMSiMelody(rawsms,
sms->UserData[i].u.Text, rawsms->UserData + rawsms->UserDataLength);
dprintf("Imelody, size %d\n", size);
rawsms->Length += size;
rawsms->UserDataLength += size;
Index: gnokii/gnokii.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/gnokii/gnokii.c,v
retrieving revision 1.251
diff -u -u -r1.251 gnokii.c
--- gnokii/gnokii.c 4 Jun 2002 22:18:30 -0000 1.251
+++ gnokii/gnokii.c 7 Jun 2002 09:52:12 -0000
@@ -465,7 +465,7 @@
GSM_Error error;
/* The maximum length of an uncompressed concatenated short message is
255 * 153 = 39015 default alphabet characters */
- int input_len, i, curpos = 0;
+ int input_len, i, curpos = 0, text_type = SMS_PlainText;
struct option options[] = {
{ "smsc", required_argument, NULL, '1'},
@@ -475,6 +475,7 @@
{ "8bit", 0, NULL, '8'},
{ "imelody", 0, NULL, 'i'},
{ "animation",required_argument,NULL, 'a'},
+ { "picture", required_argument, NULL, 'p'},
{ "concat", required_argument, NULL, 'o'},
{ NULL, 0, NULL, 0}
};
@@ -492,7 +493,7 @@
optarg = NULL;
optind = 0;
- while ((i = getopt_long(argc, argv, "r8co:C:v:i", options, NULL)) !=
-1) {
+ while ((i = getopt_long(argc, argv, "r8ca:p:o:C:v:i", options, NULL))
!= -1) {
switch (i) { /* -c for compression. not yet implemented.
*/
case '1': /* SMSC number */
strncpy(sms.SMSC.Number, optarg,
sizeof(sms.SMSC.Number) - 1);
@@ -533,11 +534,18 @@
loadbitmap(&sms.UserData[curpos].u.Animation[i], s, i ? GSM_EMSAnimation2 :
GSM_EMSAnimation);
s = t;
}
- sms.UserData[++curpos].Type = SMS_NoData;
- curpos = -1;
+ curpos++;
+ text_type = SMS_NoData;
break;
}
+ case 'p': /* EMS Picture */
+ sms.UserData[curpos].Type = SMS_BitmapData;
+ loadbitmap(&sms.UserData[curpos].u.Bitmap, optarg,
GSM_EMSPicture);
+ curpos++;
+ text_type = SMS_NoData;
+ break;
+
case 'o': /* Concat header */ {
printf("Adding concat header\n");
sms.UserData[curpos].Type = SMS_Concat;
@@ -575,30 +583,22 @@
break;
case 'i':
- sms.UserData[0].Type = SMS_iMelodyText;
- sms.UserData[1].Type = SMS_NoData;
- error = readtext(&sms.UserData[0], input_len);
- if (error != GE_NONE) return -1;
- if (sms.UserData[0].Length < 1) {
- fprintf(stderr, _("Empty message.
Quitting.\n"));
- return -1;
- }
- curpos = -1;
+ text_type = SMS_iMelodyText;
break;
default:
sendsms_usage();
}
}
- if (curpos != -1) {
+ sms.UserData[curpos].Type = text_type;
+ if (text_type != SMS_NoData) {
error = readtext(&sms.UserData[curpos], input_len);
if (error != GE_NONE) return -1;
if (sms.UserData[curpos].Length < 1) {
fprintf(stderr, _("Empty message. Quitting.\n"));
return -1;
}
- sms.UserData[curpos++].Type = SMS_PlainText;
- sms.UserData[curpos].Type = SMS_NoData;
+ sms.UserData[++curpos].Type = SMS_NoData;
}
data.SMS = &sms;
Index: include/gsm-bitmaps.h
===================================================================
RCS file: /cvsroot/gnokii/gnokii/include/gsm-bitmaps.h,v
retrieving revision 1.16
diff -u -u -r1.16 gsm-bitmaps.h
--- include/gsm-bitmaps.h 3 Jun 2002 20:30:43 -0000 1.16
+++ include/gsm-bitmaps.h 7 Jun 2002 09:52:14 -0000
@@ -76,7 +76,6 @@
API void GSM_PrintBitmap(GSM_Bitmap *bitmap);
/* SMS bitmap functions */
-int GSM_EncodeSMSBitmap(GSM_Bitmap *bitmap, char *message);
API GSM_Error GSM_ReadSMSBitmap(int type, char *message, char *code,
GSM_Bitmap *bitmap);
#endif
--
(about SSSCA) "I don't say this lightly. However, I really think that the U.S.
no longer is classifiable as a democracy, but rather as a plutocracy." --hpa
- Fix EMS + concat message, cleanup gnokii.c,
Pavel Machek <=
- Re: Fix EMS + concat message, cleanup gnokii.c, Pawel Kot, 2002/06/07
- Re: Fix EMS + concat message, cleanup gnokii.c, Pavel Machek, 2002/06/08
- Re: Fix EMS + concat message, cleanup gnokii.c, Pawel Kot, 2002/06/08
- Re: Fix EMS + concat message, cleanup gnokii.c, Pavel Machek, 2002/06/08
- Re: Fix EMS + concat message, cleanup gnokii.c, Pawel Kot, 2002/06/08
- Re: Fix EMS + concat message, cleanup gnokii.c, Pavel Machek, 2002/06/08
- Re: Fix EMS + concat message, cleanup gnokii.c, Pawel Kot, 2002/06/08
- Re: Fix EMS + concat message, cleanup gnokii.c, Pavel Machek, 2002/06/10
- Re: Fix EMS + concat message, cleanup gnokii.c, Pawel Kot, 2002/06/10
- Re: Fix EMS + concat message, cleanup gnokii.c, Pavel Machek, 2002/06/12