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) (ignore 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 | |||
@@ -1,10 +1,11 @@ | |||
1 | /* (c) 2001-2004 by Marcin Wiacek */ | 1 | /* (c) 2001-2004 by Marcin Wiacek */ |
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" |
8 | #include "gsmlogo.h" | 9 | #include "gsmlogo.h" |
9 | #include "gsmnet.h" | 10 | #include "gsmnet.h" |
10 | 11 | ||
@@ -158,12 +159,13 @@ void PHONE_DecodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *B | |||
158 | Bitmap->DefaultRingtone = false; | 159 | Bitmap->DefaultRingtone = false; |
159 | Bitmap->RingtoneID = 0; | 160 | Bitmap->RingtoneID = 0; |
160 | Bitmap->NetworkCode[0] = 0; | 161 | Bitmap->NetworkCode[0] = 0; |
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++) { |
167 | for (y=0;y<Bitmap->BitmapHeight;y++) { | 169 | for (y=0;y<Bitmap->BitmapHeight;y++) { |
168 | if (PHONE_IsPointBitmap(Type, buffer, x, y, Bitmap->BitmapWidth, Bitmap->BitmapHeight)) { | 170 | if (PHONE_IsPointBitmap(Type, buffer, x, y, Bitmap->BitmapWidth, Bitmap->BitmapHeight)) { |
169 | GSM_SetPointBitmap(Bitmap,x,y); | 171 | GSM_SetPointBitmap(Bitmap,x,y); |
@@ -623,23 +625,23 @@ GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) | |||
623 | GSM_Error error=ERR_NONE; | 625 | GSM_Error error=ERR_NONE; |
624 | 626 | ||
625 | file = fopen(FileName, "wb"); | 627 | file = fopen(FileName, "wb"); |
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); |
643 | } | 645 | } |
644 | fclose(file); | 646 | fclose(file); |
645 | 647 | ||
@@ -952,20 +954,51 @@ static GSM_Error loadwbmp(FILE *file, GSM_MultiBitmap *bitmap) | |||
952 | PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo, buffer, &bitmap->Bitmap[0]); | 954 | PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo, buffer, &bitmap->Bitmap[0]); |
953 | GSM_ReverseBitmap(&bitmap->Bitmap[0]); | 955 | GSM_ReverseBitmap(&bitmap->Bitmap[0]); |
954 | 956 | ||
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; |
961 | unsigned charbuffer[300]; | 990 | unsigned charbuffer[300]; |
962 | 991 | ||
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 | ||
969 | bitmap->Bitmap[0].DefaultBitmap = false; | 1002 | bitmap->Bitmap[0].DefaultBitmap = false; |
970 | 1003 | ||
971 | /* Attempt to identify filetype */ | 1004 | /* Attempt to identify filetype */ |
@@ -978,12 +1011,14 @@ GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) | |||
978 | } else if (memcmp(buffer, "NOL",3)==0) { | 1011 | } else if (memcmp(buffer, "NOL",3)==0) { |
979 | return loadnolngg(file,bitmap,true); | 1012 | return loadnolngg(file,bitmap,true); |
980 | } else if (memcmp(buffer, "NGG",3)==0) { | 1013 | } else if (memcmp(buffer, "NGG",3)==0) { |
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 | } |
987 | 1022 | ||
988 | void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, int *Length) | 1023 | void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, int *Length) |
989 | { | 1024 | { |