gnokii-users
[Top][All Lists]
Advanced

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

iMelody support


From: Pavel Machek
Subject: iMelody support
Date: Thu, 23 May 2002 11:59:31 +0200
User-agent: Mutt/1.3.28i

Hi!

Here it is for real... Commited.

I thought a bit if adding it as "send text" is right thing to do, but
as iMelody really is text protocol, easy to write/edit by human, and
as it will be pretty difficult to convert between rtttl and iMelody, I
guess it is right for now; otherwise some kind of ringtone abstraction
would be needed, with conversions etc...
                                                                Pavel

Index: common/gsm-ringtones.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-ringtones.c,v
retrieving revision 1.10
diff -u -u -r1.10 gsm-ringtones.c
--- common/gsm-ringtones.c      23 May 2002 09:13:16 -0000      1.10
+++ common/gsm-ringtones.c      23 May 2002 09:49:21 -0000
@@ -23,6 +23,8 @@
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
   Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml.
+  Copyright (C) 2002       Pavel Machek <address@hidden>
+  
 
   This file provides support for ringtones.
 
@@ -581,4 +583,19 @@
        int j = GSM_MAX_8BIT_SMS_LENGTH;
        GSM_PackRingtone(ringtone, message, &j);
        return j;
+}
+
+/* Returns message length */
+int GSM_EncodeSMSiMelody(char *imelody, char *message)
+{
+       unsigned short size, current = 0;
+
+       dprintf("EMS iMelody\n");
+       message[current++] = strlen(imelody)+3;
+       message[current++] = 0x0c;      /* iMelody code */
+       message[current++] = strlen(imelody)+1;
+       message[current++] = 0;               /* Position in text this melody 
is at */
+       strcpy(message+current, imelody);
+
+       return (current + strlen(imelody));
 }
Index: common/gsm-sms.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-sms.c,v
retrieving revision 1.66
diff -u -u -r1.66 gsm-sms.c
--- common/gsm-sms.c    23 May 2002 09:33:12 -0000      1.66
+++ common/gsm-sms.c    23 May 2002 09:49:30 -0000
@@ -1027,7 +1027,7 @@
 {
        SMS_AlphabetType al;
        unsigned int i, length, size = 0, offset = 0;
-       int text_index = -1, bitmap_index = -1, ringtone_index = -1;
+       int text_index = -1, bitmap_index = -1, ringtone_index = -1, 
imelody_index = -1;
        char *message = rawsms->UserData;
        GSM_Error error;
 
@@ -1044,6 +1044,8 @@
                        bitmap_index   = i; break;
                case SMS_RingtoneData:
                        ringtone_index = i; break;
+               case SMS_iMelodyText:
+                       imelody_index = i; break;
                case SMS_NoData:
                        break;
                default:
@@ -1128,6 +1130,16 @@
                default:
                        return GE_SMSWRONGFORMAT;
                }
+       }
+
+       /* iMelody coding */
+       if (imelody_index != -1) {
+               size = GSM_EncodeSMSiMelody(sms->UserData[0].u.Text, message + 
rawsms->UserDataLength);
+               printf("Imelody, size %d\n", size);
+               rawsms->Length += size;
+               rawsms->UserDataLength += size;
+               rawsms->DCS = 0xf5;
+               rawsms->UDHIndicator = 1;
        }
 
        /* Bitmap coding */
Index: gnokii/gnokii.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/gnokii/gnokii.c,v
retrieving revision 1.242
diff -u -u -r1.242 gnokii.c
--- gnokii/gnokii.c     23 May 2002 09:40:23 -0000      1.242
+++ gnokii/gnokii.c     23 May 2002 09:50:07 -0000
@@ -255,7 +255,7 @@
                     "          gnokii --deletesms memory_type start [end]\n"
                     "          gnokii --sendsms destination [--smsc 
message_center_number |\n"
                     "                 --smscno message_center_index] [-r] [-C 
n] [-v n]\n"
-                    "                 [--long n]\n"
+                    "                 [--long n] [-i]\n"
                     "          gnokii --savesms [-m] [-l n] [-i]\n"
                     "          gnokii --smsreader\n"
                     "          gnokii --getsmsc [start_number [end_number]] 
[-r|--raw]\n"
@@ -428,6 +428,7 @@
                { "long",    required_argument, NULL, '3'},
                { "picture", required_argument, NULL, '4'},
                { "8bit",    0,                 NULL, '8'},
+               { "imelody", 0,                 NULL, 'i'},
                { NULL,      0,                 NULL, 0}
        };
 
@@ -444,7 +445,9 @@
        optarg = NULL;
        optind = 0;
 
-       while ((i = getopt_long(argc, argv, "r8cC:v:", options, NULL)) != -1) {
+       sms.UserData[0].Type = SMS_PlainText;
+       sms.UserData[1].Type = SMS_NoData;
+       while ((i = getopt_long(argc, argv, "r8cC:v:i", options, NULL)) != -1) {
                switch (i) {       /* -8 is for 8-bit data, -c for compression. 
both are not yet implemented. */
                case '1': /* SMSC number */
                        strncpy(sms.SMSC.Number, optarg, 
sizeof(sms.SMSC.Number) - 1);
@@ -494,6 +497,9 @@
                        sms.DCS.u.General.Alphabet = SMS_8bit;
                        input_len = GSM_MAX_8BIT_SMS_LENGTH;
                        break;
+               case 'i':
+                       sms.UserData[0].Type = SMS_iMelodyText;
+                       break;
                default:
                        sendsms_usage();
                }
@@ -514,15 +520,14 @@
 
        /*  Null terminate. */
        message_buffer[chars_read] = 0x00;
-       if (chars_read > 0 && message_buffer[chars_read - 1] == '\n') 
message_buffer[--chars_read] = 0x00;
+       if (sms.UserData[0].Type != SMS_iMelodyText && chars_read > 0 && 
message_buffer[chars_read - 1] == '\n') 
+               message_buffer[--chars_read] = 0x00;
        if (chars_read < 1) {
                fprintf(stderr, _("Empty message. Quitting.\n"));
                return -1;
        }
-       sms.UserData[0].Type = SMS_PlainText;
        strncpy(sms.UserData[0].u.Text, message_buffer, chars_read);
        sms.UserData[0].u.Text[chars_read] = 0;
-       sms.UserData[1].Type = SMS_NoData;
        data.SMS = &sms;
 
        /* Send the message. */
Index: include/gsm-sms.h
===================================================================
RCS file: /cvsroot/gnokii/gnokii/include/gsm-sms.h,v
retrieving revision 1.34
diff -u -u -r1.34 gsm-sms.h
--- include/gsm-sms.h   19 May 2002 20:28:56 -0000      1.34
+++ include/gsm-sms.h   23 May 2002 09:50:12 -0000
@@ -302,7 +302,8 @@
        SMS_PlainText    = 0x01,
        SMS_BitmapData   = 0x02,
        SMS_RingtoneData = 0x03,
-       SMS_OtherData    = 0x04
+       SMS_iMelodyText  = 0x04,
+       SMS_OtherData    = 0x05
 } SMS_DataType;
 
 /*** FOLDER INFO ***/

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