author | zautrix <zautrix> | 2004-10-05 11:13:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-05 11:13:51 (UTC) |
commit | 50ab40e1e02ad7c65c17a78d08116a808b1257aa (patch) (unidiff) | |
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) (show 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,5 +1,7 @@ | |||
1 | /* (c) 2001-2004 by Marcin Wiacek */ | 1 | /* (c) 2001-2004 by Marcin Wiacek */ |
2 | /* Based on some work from Ralf Thelen (7110 ringtones), | 2 | /* Based on some work from Ralf Thelen (7110 ringtones) and others */ |
3 | * Gnokii (RTTL and SM) and others | 3 | /* Based on some work (RTTL and SM) from Gnokii (www.gnokii.org) |
4 | * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot | ||
5 | * GNU GPL version 2 or later | ||
4 | */ | 6 | */ |
5 | 7 | ||
@@ -8,4 +10,5 @@ | |||
8 | #include <ctype.h> | 10 | #include <ctype.h> |
9 | #include <math.h> | 11 | #include <math.h> |
12 | #include <sys/stat.h> | ||
10 | #ifdef WIN32 | 13 | #ifdef WIN32 |
11 | # include <windows.h> | 14 | # include <windows.h> |
@@ -157,4 +160,10 @@ static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone) | |||
157 | } | 160 | } |
158 | 161 | ||
162 | static GSM_Error savemmf(FILE *file, GSM_Ringtone *ringtone) | ||
163 | { | ||
164 | fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file); | ||
165 | return ERR_NONE; | ||
166 | } | ||
167 | |||
159 | GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone) | 168 | GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone) |
160 | { | 169 | { |
@@ -486,4 +495,7 @@ GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone) | |||
486 | savepuremidi(file, ringtone); | 495 | savepuremidi(file, ringtone); |
487 | break; | 496 | break; |
497 | case RING_MMF: | ||
498 | savemmf(file, ringtone); | ||
499 | break; | ||
488 | } | 500 | } |
489 | 501 | ||
@@ -770,4 +782,24 @@ static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone) | |||
770 | } | 782 | } |
771 | 783 | ||
784 | static GSM_Error loadmmf(FILE *file, GSM_Ringtone *ringtone) | ||
785 | { | ||
786 | struct stat st; | ||
787 | char *buffer; | ||
788 | int length; | ||
789 | |||
790 | dbgprintf("loading smaf file\n"); | ||
791 | fstat(fileno(file), &st); | ||
792 | ringtone->BinaryTone.Length = length = st.st_size; | ||
793 | ringtone->BinaryTone.Buffer = buffer = malloc(length); | ||
794 | if (buffer == NULL) | ||
795 | return ERR_MOREMEMORY; | ||
796 | fread(buffer, 1, length, file); | ||
797 | |||
798 | dbgprintf("Length %i name \"%s\"\n", length, | ||
799 | DecodeUnicodeString(ringtone->Name)); | ||
800 | |||
801 | return ERR_NONE; | ||
802 | } | ||
803 | |||
772 | static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone) | 804 | static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone) |
773 | { | 805 | { |
@@ -817,4 +849,8 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone) | |||
817 | ringtone->Format = RING_MIDI; | 849 | ringtone->Format = RING_MIDI; |
818 | } | 850 | } |
851 | if (buffer[0]==0x4D && buffer[1]==0x4D && | ||
852 | buffer[2]==0x4D && buffer[3]==0x44) { | ||
853 | ringtone->Format = RING_MMF; | ||
854 | } | ||
819 | } | 855 | } |
820 | rewind(file); | 856 | rewind(file); |
@@ -843,4 +879,9 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone) | |||
843 | EncodeUnicode(ringtone->Name,FileName,strlen(FileName)); | 879 | EncodeUnicode(ringtone->Name,FileName,strlen(FileName)); |
844 | error = loadpuremidi(file,ringtone); | 880 | error = loadpuremidi(file,ringtone); |
881 | break; | ||
882 | case RING_MMF: | ||
883 | EncodeUnicode(ringtone->Name,FileName,strlen(FileName)); | ||
884 | error = loadmmf(file,ringtone); | ||
885 | break; | ||
845 | } | 886 | } |
846 | fclose(file); | 887 | fclose(file); |