gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Picture SMS-es and long sms support


From: Pavel Machek
Subject: Re: Picture SMS-es and long sms support
Date: Fri, 31 May 2002 22:11:50 +0200
User-agent: Mutt/1.3.28i

Hi!

> > This is long sms-es and picture support. [Picture image support is not
> > quite complete and quite working, but with small hacks it can be made
> > to work.]
> >
> > Long sms-es is handled in slightly funny way, but I found it cleaner:
> > it is now permitted to attempt to send SMS with up to 10K of user
> > data. Code detects it and splits message accordingly.
> 
> Pavel, I belive the patch is incorrect. Please revert it. See the comments
> below.

Does this look like fixing most uglyness? Okay to commit?

                                                                Pavel

Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnokii/gnokii/ChangeLog,v
retrieving revision 1.151
diff -u -u -r1.151 ChangeLog
--- ChangeLog   29 May 2002 02:09:01 -0000      1.151
+++ ChangeLog   31 May 2002 20:09:50 -0000
@@ -7,6 +7,7 @@
     o support for sending iMelody                      (Pavel Machek)
     o reactivate support for text before picture messages
                                                        (Markus Plail)
+    o support for sending nokia logos and picture msgs (Pavel Machek)
  * AT series updates:
     o Security functions for AT phones              (Manfred Jonsson)
  * code fixes:
Index: common/gsm-bitmaps.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-bitmaps.c,v
retrieving revision 1.25
diff -u -u -r1.25 gsm-bitmaps.c
--- common/gsm-bitmaps.c        30 May 2002 09:39:26 -0000      1.25
+++ common/gsm-bitmaps.c        31 May 2002 20:09:55 -0000
@@ -237,7 +237,6 @@
                message[current++]=0x02;     /* ID for bitmap, 0x06 is id for 
screensaver */
 #else
                message[current++]=0x06;     /* ID for bitmap, 0x06 is id for 
screensaver */
-               strcpy(bitmap->text, "");
 #endif
                message[current++]=0x01;     /* Length for picture part, hi */
                message[current++]=0x00;     /* length lo */
@@ -250,23 +249,6 @@
 
                memcpy(message+current,bitmap->bitmap,bitmap->size);
                current=current+bitmap->size;
-
-               if (strlen(bitmap->text)!=0) {
-                       /* FIXME: unicode length is not as simple as strlen */
-                       int uni = 0, len;                    /* 0 .. 
ISO-8859-1, 1 .. Unicode */
-
-                       message[current++]=uni;
-
-                       /* Length for text part */
-                       len = strlen(bitmap->text)*(uni + 1);
-                       message[current++]=0x00;
-                       message[current++]=len;
-                       if (uni)
-                               EncodeUnicode 
(message+current,bitmap->text,strlen(bitmap->text));
-                       else
-                               
memcpy(message+current,bitmap->text,strlen(bitmap->text));
-                       current += len;
-               }
                return current;
        case GSM_EMSPicture:
                dprintf("EMS picture\n");
Index: common/gsm-sms.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-sms.c,v
retrieving revision 1.82
diff -u -u -r1.82 gsm-sms.c
--- common/gsm-sms.c    30 May 2002 09:39:26 -0000      1.82
+++ common/gsm-sms.c    31 May 2002 20:10:08 -0000
@@ -36,21 +36,16 @@
 #include "gsm-encoding.h"
 #include "gsm-statemachine.h"
 
-#define BITMAP_SUPPORT 1
-#define RINGTONE_SUPPORT 1
-
-#ifdef BITMAP_SUPPORT
 #  include "gsm-ringtones.h"
-#endif
-#ifdef RINGTONE_SUPPORT
 #  include "gsm-bitmaps.h"
-#endif
 
 struct udh_data {
        unsigned int length;
        char *header;
 };
 
+#define MAX_SMS_PART 128
+
 /* User data headers */
 static struct udh_data headers[] = {
        { 0x00, "" },
@@ -58,7 +53,7 @@
        { 0x06, "\x05\x04\x15\x81\x00\x00" }, /* Ringtones */
        { 0x06, "\x05\x04\x15\x82\x00\x00" }, /* Operator logos */
        { 0x06, "\x05\x04\x15\x83\x00\x00" }, /* Caller logos */
-       { 0x0B, "\x05\x04\x15\x8a\x00\x00\x00\x03\xce\x03\x01" }, /* Multipart 
Message */
+       { 0x06, "\x05\x04\x15\x8a\x00\x00" }, /* Multipart Message */
        { 0x06, "\x05\x04\x23\xf4\x00\x00" }, /* WAP vCard */
        { 0x06, "\x05\x04\x23\xf5\x00\x00" }, /* WAP vCalendar */
        { 0x06, "\x05\x04\x23\xf6\x00\x00" }, /* WAP vCardSecure */
@@ -575,6 +570,7 @@
        case SMS_Picture:
                /* This is incredible. Nokia violates it's own format in 6210 */
                /* Indicate that it is Multipart Message. Remove it if not 
needed */
+               /* [I believe Nokia said in their manuals that any order is 
permitted --pavel] */
                sms->UDH.Number = 1;
                sms->UDH.UDH[0].Type = SMS_MultipartMessage;
                if ((rawsms->UserData[0] == 0x48) && (rawsms->UserData[1] == 
0x1c)) {
@@ -1084,13 +1080,12 @@
                error = GE_NONE;
                switch (sms->UserData[0].u.Bitmap.type) {
                case GSM_OperatorLogo: error = EncodeUDH(rawsms, SMS_OpLogo, 
message); break;
+               case GSM_PictureMessage: 
                case GSM_EMSPicture:
-               case GSM_PictureMessage:
                case GSM_EMSAnimation: break;   /* We'll construct headers in 
EncodeSMSBitmap */
                }
                if (error != GE_NONE) return error;
 
-#ifdef BITMAP_SUPPORT
                if (text_index != -1) {         /* This is quite a dirty hack */
                        if (sms->UserData[0].u.Bitmap.type != 
GSM_PictureMessage)
                                return GE_SMSWRONGFORMAT;
@@ -1103,9 +1098,6 @@
                rawsms->UserDataLength += size;
                rawsms->DCS = 0xf5;
                rawsms->UDHIndicator = 1;
-#else
-               return GE_NOTSUPPORTED;
-#endif
        }
 
        /* Text Coding */
@@ -1165,30 +1157,33 @@
        if (multi_index != -1) {
                size = sms->UserData[0].Length;
                error = EncodeUDH(rawsms, 0x05, message);
+               if (error != GE_NONE) return error;
+
+               message[0] += 5;
+               rawsms->Length += 5;
+               rawsms->UserDataLength += 5;
+               rawsms->UserData[ 7] = 0x00;
+               rawsms->UserData[ 8] = 0x03;
+               rawsms->UserData[ 9] = 0xce;
                rawsms->UserData[10] = sms->UserData[multi_index].u.Multi.total;
                rawsms->UserData[11] = sms->UserData[multi_index].u.Multi.this;
-               if (error != GE_NONE) return error;
-               memcpy(message + rawsms->UserDataLength, 
sms->UserData[multi_index].u.Multi.Binary, 128);
+
+               memcpy(message + rawsms->UserDataLength, 
sms->UserData[multi_index].u.Multi.Binary, MAX_SMS_PART);
                rawsms->Length += size;
                rawsms->UserDataLength += size;
                rawsms->DCS = 0xf5;
                rawsms->UDHIndicator = 1;               
        }
 
-
        /* Ringtone coding */
        if (ringtone_index != -1) {
                error = EncodeUDH(rawsms, SMS_Ringtone, message); 
                if (error != GE_NONE) return error;
-#ifdef RINGTONE_SUPPORT
                size = GSM_EncodeSMSRingtone(message + rawsms->Length, 
&sms->UserData[ringtone_index].u.Ringtone);
                rawsms->Length += size;
                rawsms->UserDataLength += size;
                rawsms->DCS = 0xf5;
                rawsms->UDHIndicator = 1;
-#else
-               return GE_NOTSUPPORTED;
-#endif
        }
        return GE_NONE;
 }
@@ -1238,16 +1233,15 @@
        LongSMS = *data->RawSMS;
        sms = *data->SMS;
 
-       DumpRawSMS(rawsms);
-       count = (rawsms->UserDataLength + 127) / 128;
-       printf("Will need %d sms-es\n", count);
+       count = (rawsms->UserDataLength + MAX_SMS_PART -1) / MAX_SMS_PART;
+       dprintf("Will need %d sms-es\n", count);
        for (i=0; i<count; i++) {
                printf("Sending sms #%d\n", i);
                sms.UserData[0].Type = SMS_MultiData;
-               sms.UserData[0].Length = 128;
+               sms.UserData[0].Length = MAX_SMS_PART;
                if (i+1 == count)
-                       sms.UserData[0].Length = rawsms->UserDataLength % 128;
-               memcpy(sms.UserData[0].u.Multi.Binary, rawsms->UserData + 
i*128, 128);
+                       sms.UserData[0].Length = rawsms->UserDataLength % 
MAX_SMS_PART;
+               memcpy(sms.UserData[0].u.Multi.Binary, rawsms->UserData + 
i*MAX_SMS_PART, MAX_SMS_PART);
                sms.UserData[0].u.Multi.this = i+1;
                sms.UserData[0].u.Multi.total = count;
                sms.UserData[1].Type = SMS_NoData;
Index: include/gsm-sms.h
===================================================================
RCS file: /cvsroot/gnokii/gnokii/include/gsm-sms.h,v
retrieving revision 1.39
diff -u -u -r1.39 gsm-sms.h
--- include/gsm-sms.h   29 May 2002 23:09:58 -0000      1.39
+++ include/gsm-sms.h   31 May 2002 20:10:14 -0000
@@ -44,6 +44,7 @@
 /* Limits of SMS messages. */
 #define GSM_MAX_SMS_LENGTH             160
 #define GSM_MAX_8BIT_SMS_LENGTH        140
+#define GSM_MAX_LONG_LENGTH         10240
 
 #define SMS_MAX_PART_NUMBER              3
 
@@ -442,7 +443,7 @@
        unsigned int DCS;                              /* Data Coding Scheme 
(9.2.3.10) */
        unsigned int Length;                           /* User Data Length 
(9.2.3.16), Command Data Length (9.2.3.20) */
        bool UDHIndicator;
-       unsigned char UserData[10240];                 /* User Data (9.2.3.24), 
Command Data (9.2.3.21), extened to Nokia Multipart Messages from Smart 
Messaging Specification 3.0.0 */
+       unsigned char UserData[GSM_MAX_LONG_LENGTH];   /* User Data (9.2.3.24), 
Command Data (9.2.3.21), extened to Nokia Multipart Messages from Smart 
Messaging Specification 3.0.0 */
        int UserDataLength;                            /* Length of just 
previous field */
 
        bool ValidityIndicator;

-- 
(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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]