Репозиторий ALT Linux backports/2.4
Последнее обновление: 9 июля 2008 | Пакетов: 497 | Посещений: 1574727
 поиск   регистрация   авторизация 
 
Группа :: Коммуникации
Пакет: gammu

 Главная   Изменения   Спек   Патчи   Загрузить   Bugs and FR 

Патч: gammu-1.02.0-at-utf8.patch


diff -ruNp gammu-1.02.0.orig/common/phone/at/atgen.c gammu-1.02.0/common/phone/at/atgen.c
--- gammu-1.02.0.orig/common/phone/at/atgen.c	2005-07-27 14:58:22.000000000 +0200
+++ gammu-1.02.0/common/phone/at/atgen.c	2005-09-19 15:06:36.896839318 +0200
@@ -27,6 +27,7 @@ GSM_Error ALCATEL_ProtocolVersionReply (
 typedef struct {
 	GSM_AT_Charset	charset;
 	char		*text;
+	bool		unicode;
 } GSM_AT_Charset_Info;
 
 /**
@@ -34,10 +35,11 @@ typedef struct {
  * defines their preferences, so if first is found it is used.
  */
 static GSM_AT_Charset_Info AT_Charsets[] = {
-	{AT_CHARSET_HEX,	"HEX"},
-	{AT_CHARSET_GSM,	"GSM"},
-	{AT_CHARSET_PCCP437,	"PCCP437"},
-	{AT_CHARSET_UCS2,	"UCS2"},
+	{AT_CHARSET_HEX,	"HEX",		false},
+	{AT_CHARSET_GSM,	"GSM",		false},
+	{AT_CHARSET_PCCP437,	"PCCP437",	false},
+	{AT_CHARSET_UTF8,	"UTF-8",		true},
+	{AT_CHARSET_UCS2,	"UCS2",		true},
 	{0,			NULL}
 };
 
@@ -821,9 +823,15 @@ GSM_Error ATGEN_ReplyGetCharsets(GSM_Pro
 				return ERR_UNKNOWNRESPONSE;
 			}
 			/* Then find good charset for unicode: */
-			if (strstr(line, "UCS2") != NULL) {
-				Priv->UnicodeCharset = AT_CHARSET_UCS2;
-			} else {
+			Priv->UnicodeCharset = 0;
+			while (AT_Charsets[i].charset != 0) {
+				if (AT_Charsets[i].unicode && (strstr(line, AT_Charsets[i].text) != NULL)) {
+					Priv->UnicodeCharset = AT_Charsets[i].charset;
+					break;
+				}
+				i++;
+			}
+			if (Priv->UnicodeCharset == 0) {
 				Priv->UnicodeCharset = Priv->NormalCharset;
 			}
 			return ERR_NONE;
@@ -2648,6 +2656,9 @@ GSM_Error ATGEN_ReplyGetMemory(GSM_Proto
   		case AT_CHARSET_UCS2:
  			DecodeHexUnicode(Memory->Entries[1].Text, buffer + offset, strlen(buffer) - (offset * 2));
   			break;
+  		case AT_CHARSET_UTF8:
+ 			DecodeUTF8(Memory->Entries[1].Text, buffer + offset, strlen(buffer) - (offset * 2));
+  			break;
   		case AT_CHARSET_PCCP437:
   			/* FIXME: correctly decode PCCP437 */
   			DecodeDefault(Memory->Entries[1].Text, buffer + offset, strlen(buffer) - (offset * 2), false, NULL);
@@ -3208,6 +3219,10 @@ GSM_Error ATGEN_PrivSetMemory(GSM_StateM
 			EncodeHexUnicode(name, entry->Entries[Name].Text, UnicodeLength(entry->Entries[Name].Text));
 			len = strlen(name);
 			break;
+  		case AT_CHARSET_UTF8:
+			EncodeUTF8(name, entry->Entries[Name].Text);
+			len = strlen(name);
+  			break;
 		case AT_CHARSET_PCCP437:
 			/* FIXME: correctly decode PCCP437 */
 			smprintf(s, "str: %s\n", DecodeUnicodeString(entry->Entries[Name].Text));
Files gammu-1.02.0.orig/common/phone/at/.atgen.c.swp and gammu-1.02.0/common/phone/at/.atgen.c.swp differ
diff -ruNp gammu-1.02.0.orig/common/phone/at/atgen.h gammu-1.02.0/common/phone/at/atgen.h
--- gammu-1.02.0.orig/common/phone/at/atgen.h	2005-02-08 22:00:18.000000000 +0100
+++ gammu-1.02.0/common/phone/at/atgen.h	2005-09-19 14:58:57.783520967 +0200
@@ -50,6 +50,7 @@ typedef enum {
 	AT_CHARSET_HEX = 1,
 	AT_CHARSET_GSM,
 	AT_CHARSET_UCS2,
+	AT_CHARSET_UTF8,
 	AT_CHARSET_PCCP437
 } GSM_AT_Charset;
 
 
design & coding: Vladimir Lettiev aka crux © 2004-2005