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/gsmlogo.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/gsmlogo.c') (more/less context) (show whitespace changes)
-rw-r--r-- | gammu/emb/common/service/gsmlogo.c | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/gammu/emb/common/service/gsmlogo.c b/gammu/emb/common/service/gsmlogo.c index c992915..7c19967 100644 --- a/gammu/emb/common/service/gsmlogo.c +++ b/gammu/emb/common/service/gsmlogo.c | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #include <sys/stat.h> | ||
5 | 6 | ||
6 | #include "../misc/misc.h" | 7 | #include "../misc/misc.h" |
7 | #include "../misc/coding/coding.h" | 8 | #include "../misc/coding/coding.h" |
@@ -161,6 +162,7 @@ void PHONE_DecodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *B | |||
161 | Bitmap->Sender[0] = 0; | 162 | Bitmap->Sender[0] = 0; |
162 | Bitmap->Sender[1] = 0; | 163 | Bitmap->Sender[1] = 0; |
163 | Bitmap->ID = 0; | 164 | Bitmap->ID = 0; |
165 | Bitmap->Name = NULL; | ||
164 | 166 | ||
165 | GSM_ClearBitmap(Bitmap); | 167 | GSM_ClearBitmap(Bitmap); |
166 | for (x=0;x<Bitmap->BitmapWidth;x++) { | 168 | for (x=0;x<Bitmap->BitmapWidth;x++) { |
@@ -626,17 +628,17 @@ GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) | |||
626 | if (file == NULL) return ERR_CANTOPENFILE; | 628 | if (file == NULL) return ERR_CANTOPENFILE; |
627 | 629 | ||
628 | /* Attempt to identify filetype */ | 630 | /* Attempt to identify filetype */ |
629 | if (strstr(FileName,".nlm")) { | 631 | if (mystrcasestr(FileName,".nlm")) { |
630 | error=savenlm(file,bitmap); | 632 | error=savenlm(file,bitmap); |
631 | } else if (strstr(FileName,".ngg")) { | 633 | } else if (mystrcasestr(FileName,".ngg")) { |
632 | error=savengg(file,bitmap); | 634 | error=savengg(file,bitmap); |
633 | } else if (strstr(FileName,".nol")) { | 635 | } else if (mystrcasestr(FileName,".nol")) { |
634 | error=savenol(file,bitmap); | 636 | error=savenol(file,bitmap); |
635 | } else if (strstr(FileName,".xpm")) { | 637 | } else if (mystrcasestr(FileName,".xpm")) { |
636 | error=savexpm(file,bitmap); | 638 | error=savexpm(file,bitmap); |
637 | } else if (strstr(FileName,".nsl")) { | 639 | } else if (mystrcasestr(FileName,".nsl")) { |
638 | error=savensl(file,bitmap); | 640 | error=savensl(file,bitmap); |
639 | } else if (strstr(FileName,".wbmp")) { | 641 | } else if (mystrcasestr(FileName,".wbmp")) { |
640 | error=savewbmp(file,bitmap); | 642 | error=savewbmp(file,bitmap); |
641 | } else { | 643 | } else { |
642 | error=savebmp(file,bitmap); | 644 | error=savebmp(file,bitmap); |
@@ -955,6 +957,33 @@ static GSM_Error loadwbmp(FILE *file, GSM_MultiBitmap *bitmap) | |||
955 | return ERR_NONE; | 957 | return ERR_NONE; |
956 | } | 958 | } |
957 | 959 | ||
960 | static GSM_Error loadgif(FILE *file, GSM_MultiBitmap *bitmap) | ||
961 | { | ||
962 | GSM_Bitmap *bmap = &bitmap->Bitmap[0]; | ||
963 | char *buffer; | ||
964 | struct stat st; | ||
965 | int length; | ||
966 | |||
967 | dbgprintf("loading gif file\n"); | ||
968 | fstat(fileno(file), &st); | ||
969 | bmap->BinaryPic.Length = length = st.st_size; | ||
970 | bmap->BinaryPic.Buffer = buffer = malloc(length); | ||
971 | if (bmap->BinaryPic.Buffer == NULL) | ||
972 | return ERR_MOREMEMORY; | ||
973 | |||
974 | fread(buffer, 1, length, file); | ||
975 | dbgprintf("Length %i name \"%s\"\n", length, | ||
976 | DecodeUnicodeString(bmap->Name)); | ||
977 | |||
978 | bmap->Type = GSM_PictureBinary; | ||
979 | bmap->BinaryPic.Type = PICTURE_GIF; | ||
980 | bmap->BitmapWidth = 256 * buffer[7] + buffer[6]; | ||
981 | bmap->BitmapHeight = 256 * buffer[9] + buffer[8]; | ||
982 | bitmap->Number = 1; | ||
983 | |||
984 | return ERR_NONE; | ||
985 | } | ||
986 | |||
958 | GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) | 987 | GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) |
959 | { | 988 | { |
960 | FILE *file; | 989 | FILE *file; |
@@ -963,6 +992,10 @@ GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) | |||
963 | file = fopen(FileName, "rb"); | 992 | file = fopen(FileName, "rb"); |
964 | if (file == NULL) return ERR_CANTOPENFILE; | 993 | if (file == NULL) return ERR_CANTOPENFILE; |
965 | 994 | ||
995 | bitmap->Bitmap[0].Name = malloc((strlen(FileName) + 1) * 2); | ||
996 | if (bitmap->Bitmap[0].Name == NULL) return ERR_MOREMEMORY; | ||
997 | EncodeUnicode(bitmap->Bitmap[0].Name, FileName, strlen(FileName)); | ||
998 | |||
966 | fread(buffer, 1, 9, file); /* Read the header of the file. */ | 999 | fread(buffer, 1, 9, file); /* Read the header of the file. */ |
967 | rewind(file); | 1000 | rewind(file); |
968 | 1001 | ||
@@ -981,6 +1014,8 @@ GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) | |||
981 | return loadnolngg(file,bitmap,false); | 1014 | return loadnolngg(file,bitmap,false); |
982 | } else if (memcmp(buffer, "FORM",4)==0) { | 1015 | } else if (memcmp(buffer, "FORM",4)==0) { |
983 | return loadnsl(file,bitmap); | 1016 | return loadnsl(file,bitmap); |
1017 | } else if (memcmp(buffer, "GIF",3)==0) { | ||
1018 | return loadgif(file,bitmap); | ||
984 | } | 1019 | } |
985 | return ERR_UNKNOWN; | 1020 | return ERR_UNKNOWN; |
986 | } | 1021 | } |