summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/service/gsmring.c
authorzautrix <zautrix>2004-10-05 11:13:51 (UTC)
committer zautrix <zautrix>2004-10-05 11:13:51 (UTC)
commit50ab40e1e02ad7c65c17a78d08116a808b1257aa (patch) (side-by-side diff)
tree0d1939e2297fa7bbd8e1f2030f154463854164c6 /gammu/emb/common/service/gsmring.c
parentcf8616f64f20e5448d4ff644f7cc15750cf3f85f (diff)
downloadkdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.zip
kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.gz
kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.bz2
updated to latest gammu version
Diffstat (limited to 'gammu/emb/common/service/gsmring.c') (more/less context) (show whitespace changes)
-rw-r--r--gammu/emb/common/service/gsmring.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/gammu/emb/common/service/gsmring.c b/gammu/emb/common/service/gsmring.c
index 7df46f1..dab028c 100644
--- a/gammu/emb/common/service/gsmring.c
+++ b/gammu/emb/common/service/gsmring.c
@@ -1,15 +1,18 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* Based on some work from Ralf Thelen (7110 ringtones),
- * Gnokii (RTTL and SM) and others
+/* Based on some work from Ralf Thelen (7110 ringtones) and others */
+/* Based on some work (RTTL and SM) from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
*/
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
+#include <sys/stat.h>
#ifdef WIN32
# include <windows.h>
#endif
#include "../gsmcomon.h"
#include "../misc/coding/coding.h"
@@ -153,12 +156,18 @@ static GSM_Error savebin(FILE *file, GSM_Ringtone *ringtone)
static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone)
{
fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
return ERR_NONE;
}
+static GSM_Error savemmf(FILE *file, GSM_Ringtone *ringtone)
+{
+ fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
+ return ERR_NONE;
+}
+
GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone)
{
GSM_RingNoteScale DefNoteScale;
GSM_RingNoteDuration DefNoteDuration;
GSM_RingNoteStyle DefNoteStyle=0;
@@ -482,12 +491,15 @@ GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
case RING_NOKIABINARY:
savebin(file, ringtone);
break;
case RING_MIDI:
savepuremidi(file, ringtone);
break;
+ case RING_MMF:
+ savemmf(file, ringtone);
+ break;
}
fclose(file);
return ERR_NONE;
}
@@ -766,12 +778,32 @@ static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone)
ringtone->NokiaBinary.Length=fread(buffer, 1, 30000, file);
memcpy(ringtone->NokiaBinary.Frame,buffer,ringtone->NokiaBinary.Length);
dbgprintf("Length %i name \"%s\"\n",ringtone->NokiaBinary.Length,DecodeUnicodeString(ringtone->Name));
return ERR_NONE;
}
+static GSM_Error loadmmf(FILE *file, GSM_Ringtone *ringtone)
+{
+ struct stat st;
+ char *buffer;
+ int length;
+
+ dbgprintf("loading smaf file\n");
+ fstat(fileno(file), &st);
+ ringtone->BinaryTone.Length = length = st.st_size;
+ ringtone->BinaryTone.Buffer = buffer = malloc(length);
+ if (buffer == NULL)
+ return ERR_MOREMEMORY;
+ fread(buffer, 1, length, file);
+
+ dbgprintf("Length %i name \"%s\"\n", length,
+ DecodeUnicodeString(ringtone->Name));
+
+ return ERR_NONE;
+}
+
static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone)
{
unsigned char buffer[2000];
ringtone->NokiaBinary.Length=fread(buffer, 1, 500, file);
@@ -813,12 +845,16 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
ringtone->Format = RING_NOKIABINARY;
}
if (buffer[0]==0x4D && buffer[1]==0x54 &&
buffer[2]==0x68 && buffer[3]==0x64) {
ringtone->Format = RING_MIDI;
}
+ if (buffer[0]==0x4D && buffer[1]==0x4D &&
+ buffer[2]==0x4D && buffer[3]==0x44) {
+ ringtone->Format = RING_MMF;
+ }
}
rewind(file);
switch (ringtone->Format) {
case RING_NOTETONE:
if (buffer[0]==0x02 && buffer[1]==0x4A) {
error=loadott(file,ringtone);
@@ -839,12 +875,17 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
error=loadre(file,ringtone);
}
break;
case RING_MIDI:
EncodeUnicode(ringtone->Name,FileName,strlen(FileName));
error = loadpuremidi(file,ringtone);
+ break;
+ case RING_MMF:
+ EncodeUnicode(ringtone->Name,FileName,strlen(FileName));
+ error = loadmmf(file,ringtone);
+ break;
}
fclose(file);
return(error);
}
/* -------------------------- required with Nokia & RTTL ------------------- */