gnokii-users
[Top][All Lists]
Advanced

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

Fixing ringtones


From: Pavel Machek
Subject: Fixing ringtones
Date: Thu, 23 May 2002 11:14:54 +0200
User-agent: Mutt/1.3.28i

Hi!

This patch fixes ringtone handling. It is going to CVS. It seems to
work but I can't test it against real hardware. Could someone try to
send ringtone to himself to confirm it works okay?
                                                                Pavel

Index: common/gsm-ringtones.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-ringtones.c,v
retrieving revision 1.9
diff -u -u -r1.9 gsm-ringtones.c
--- common/gsm-ringtones.c      17 May 2002 00:22:09 -0000      1.9
+++ common/gsm-ringtones.c      23 May 2002 09:08:10 -0000
@@ -579,5 +579,6 @@
 int GSM_EncodeSMSRingtone(char *message, GSM_Ringtone *ringtone)
 {
        int j = GSM_MAX_8BIT_SMS_LENGTH;
-       return GSM_PackRingtone(ringtone, message, &j);
+       GSM_PackRingtone(ringtone, message, &j);
+       return j;
 }
Index: common/gsm-sms.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-sms.c,v
retrieving revision 1.64
diff -u -u -r1.64 gsm-sms.c
--- common/gsm-sms.c    21 May 2002 09:05:54 -0000      1.64
+++ common/gsm-sms.c    23 May 2002 09:08:20 -0000
@@ -1044,8 +1044,10 @@
                        bitmap_index   = i; break;
                case SMS_RingtoneData:
                        ringtone_index = i; break;
-               default:
+               case SMS_NoData:
                        break;
+               default:
+                       fprintf(stderr, "What kind of ninja-mutant UserData is 
this?\n");
                }
        }
 
@@ -1130,7 +1132,6 @@
 
        /* Bitmap coding */
        if (bitmap_index != -1) {
-               rawsms->UDHIndicator = 1;
                error = GE_NONE;
                switch (sms->UserData[0].u.Bitmap.type) {
                case GSM_OperatorLogo: error = EncodeUDH(rawsms, SMS_OpLogo, 
message); break;
@@ -1144,6 +1145,7 @@
                rawsms->Length += size;
                rawsms->UserDataLength += size;
                rawsms->DCS = 0xf5;
+               rawsms->UDHIndicator = 1;
 #else
                return GE_NOTSUPPORTED;
 #endif
@@ -1151,10 +1153,14 @@
 
        /* 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
Index: gnokii/gnokii.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/gnokii/gnokii.c,v
retrieving revision 1.240
diff -u -u -r1.240 gnokii.c
--- gnokii/gnokii.c     21 May 2002 09:05:54 -0000      1.240
+++ gnokii/gnokii.c     23 May 2002 09:08:58 -0000
@@ -901,7 +901,7 @@
        folder.FolderID = 0;
        /* Now retrieve the requested entries. */
        for (count = start_message; count <= end_message; count ++) {
-               bool done;
+               bool done = false;
                int offset = 0;
 
                memset(&message, 0, sizeof(GSM_API_SMS));
@@ -1441,17 +1441,15 @@
        }
 
        /* FIXME: read from the stdin */
+       sms.UserData[1].Type = SMS_NoData;
        if (sms.UserData[0].u.Bitmap.type == GSM_PictureImage) {
                sms.UserData[1].Type = SMS_PlainText;
                sms.UserData[2].Type = SMS_NoData;
                strcpy(sms.UserData[1].u.Text, "testtest");
-       } else {
-               sms.UserData[1].Type = SMS_NoData;
        }
 
        /* Send the message. */
        data.SMS = &sms;
-
        error = SendSMS(&data, &State);
 
        if (error == GE_NONE) fprintf(stdout, _("Send succeeded!\n"));
@@ -2994,17 +2992,25 @@
 
 static int sendringtone(int argc, char *argv[])
 {
-       GSM_Ringtone ringtone;
+       GSM_API_SMS sms;
        GSM_Error error = GE_NOTSUPPORTED;
 
-       fprintf(stderr, "Sorry, sending ringtones is currently b0rken.\n");
+       DefaultSubmitSMS(&sms);
+       sms.UserData[0].Type = SMS_RingtoneData;
+       sms.UserData[1].Type = SMS_NoData;
 
-       if (GSM_ReadRingtoneFile(argv[0], &ringtone)) {
+       if (GSM_ReadRingtoneFile(argv[0], &sms.UserData[0].u.Ringtone)) {
                fprintf(stdout, _("Failed to load ringtone.\n"));
                return(-1);
        }
 
-/*     if (GSM && GSM->SendRingtone) error = 
GSM->SendRingtone(&ringtone,argv[1]); */
+       /* The second argument is the destination, ie the phone number of 
recipient. */
+       memset(&sms.Remote.Number, 0, sizeof(sms.Remote.Number));
+       strncpy(sms.Remote.Number, argv[1], sizeof(sms.Remote.Number) - 1);
+
+       /* Send the message. */
+       data.SMS = &sms;
+       error = SendSMS(&data, &State);
 
        if (error == GE_NONE)
                fprintf(stdout, _("Send succeeded!\n"));

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