author | zautrix <zautrix> | 2004-10-05 11:13:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-05 11:13:51 (UTC) |
commit | 50ab40e1e02ad7c65c17a78d08116a808b1257aa (patch) (side-by-side diff) | |
tree | 0d1939e2297fa7bbd8e1f2030f154463854164c6 /gammu/emb/common/service/gsmring.c | |
parent | cf8616f64f20e5448d4ff644f7cc15750cf3f85f (diff) | |
download | kdepimpi-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) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/common/service/gsmring.c | 45 |
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,12 +1,15 @@ /* (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 @@ -156,6 +159,12 @@ static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone) 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; @@ -485,6 +494,9 @@ GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone) case RING_MIDI: savepuremidi(file, ringtone); break; + case RING_MMF: + savemmf(file, ringtone); + break; } fclose(file); @@ -769,6 +781,26 @@ static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone) 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]; @@ -816,6 +848,10 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone) 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) { @@ -842,6 +878,11 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone) 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); |