SOURCES: gg2-erasms.patch (NEW) Fix for new style sms sending

tiwek tiwek at pld-linux.org
Tue Sep 6 20:34:29 CEST 2005


Author: tiwek                        Date: Tue Sep  6 18:34:29 2005 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
Fix for new style sms sending

---- Files affected:
SOURCES:
   gg2-erasms.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/gg2-erasms.patch
diff -u /dev/null SOURCES/gg2-erasms.patch:1.1
--- /dev/null	Tue Sep  6 20:34:29 2005
+++ SOURCES/gg2-erasms.patch	Tue Sep  6 20:34:24 2005
@@ -0,0 +1,145 @@
+diff -Nur gg2-2.2.7.orig/src/plugins/sms/sms_core.c gg2-2.2.7/src/plugins/sms/sms_core.c
+--- gg2-2.2.7.orig/src/plugins/sms/sms_core.c	2004-12-20 09:15:38.000000000 +0000
++++ gg2-2.2.7/src/plugins/sms/sms_core.c	2005-09-01 16:15:02.000000000 +0000
+@@ -1,4 +1,4 @@
+-/* $Id$ */
++/* $Id$ */
+ 
+ /*
+  * SMS plugin for GNU Gadu 2
+@@ -605,17 +605,17 @@
+ }
+ 
+ /* wyslanie na ere */
+-gint send_ERA(SMS * message, int *era_left)
++gint send_ERA(SMS * message, gint *era_left)
+ {
+ 	gchar *recv_buff = NULL;
+ 	gchar *returncode = NULL;
+ 	gchar *get = NULL;
+ 	gchar temp[2];
+ 	gchar *sms_number = message->number;
+-	gchar *sender = NULL;
+ 	gchar *body = NULL;
+ 	gchar *era_login = NULL;
+ 	gchar *era_password = NULL;
++	gchar *logintmp = message->era_login;
+ 	gint i = 0;
+ 	gint ret = ERR_UNKNOWN;
+ 	HTTPstruct *HTTP;
+@@ -637,19 +637,24 @@
+ 	if (g_str_has_prefix(sms_number, "0"))
+ 		sms_number++;
+ 
+-	sender = ggadu_sms_urlencode(g_strdup(message->sender));
+-	body = ggadu_sms_urlencode(g_strdup(message->body));
+-	era_login = ggadu_sms_urlencode(g_strdup(message->era_login));
++	if (g_str_has_prefix(logintmp, "+"))
++		logintmp++;
++
++	if (g_str_has_prefix(logintmp, "48"))
++		logintmp += 2;
++
++	if (g_str_has_prefix(logintmp, "0"))
++		logintmp++;
++
++	body = ggadu_sms_urlencode(g_strdup_printf("%s: %s", message->sender, message->body));
++	era_login = ggadu_sms_urlencode(g_strdup(logintmp));
+ 	era_password = ggadu_sms_urlencode(g_strdup(message->era_password));
+ 
+ 	/* *INDENT-OFF* */
+-	get = g_strconcat ("?login=", era_login, "&password=", era_password,
+-			"&message=", body, "&number=48", sms_number,
+-			"&contact=", "&signature=", sender,
+-			"&success=OK", "&failure=FAIL", "&minute=", "&hour= ", NULL);
++	get = g_strdup_printf("?login=48%s&password=%s&message=%s&number=48%s&success=OK&failure=FAIL&mms=no ",
++		 era_login, era_password, body, sms_number);
+ 	/* *INDENT-ON* */
+ 
+-	g_free(sender);
+ 	g_free(body);
+ 	g_free(era_login);
+ 	g_free(era_password);
+@@ -669,15 +674,16 @@
+ 
+ 	close(sock_s);
+ 
++
+ 	if (!strlen(recv_buff))
+ 	{
+ 		ret = ERR_SERVICE;
+ 		goto out;
+ 	}
+ 
+-	if ((returncode = g_strstr_len(recv_buff, i, "OK?X-ERA-counter=")) != NULL)
++	if ((returncode = g_strstr_len(recv_buff, i, "OK?X-ERA-error=0&X-ERA-counter=")) != NULL)
+ 	{
+-		*era_left = (int) (*(returncode + 17) - '0');
++		*era_left = (gint) (*(returncode + 31) - '0');
+ 		ret = TRUE;
+ 	}
+ 	else if ((returncode = g_strstr_len(recv_buff, i, "FAIL?X-ERA-error=")) != NULL)
+@@ -701,13 +707,15 @@
+ 			ret = ERR_BAD_RCPT;
+ 		else if (r == GGADU_SMS_ERA_ERR_MSG_TOO_LONG)
+ 			ret = ERR_MSG_TOO_LONG;
++		else if (r == GGADU_SMS_ERA_ERR_INSUFF_TOKENS)
++			ret = ERR_INSUFF_TOKENS;
+ 		else
+ 			ret = ERR_UNKNOWN;
+ 	}
+ 
+       out:
+-	g_free(recv_buff);
+ 	g_free(returncode);
++	g_free(recv_buff);
+ 
+ 	return ret;
+ }
+@@ -884,6 +892,9 @@
+ 	case ERR_SERVICE:
+ 		sms_warning(message->number, _("Cannot connect!"));
+ 		break;
++	case ERR_INSUFF_TOKENS:
++		sms_warning(message->number, _("Insufficent number of tokens!"));
++		break;
+ 
+ 		/* unknowns */
+ 	case ERR_UNKNOWN:
+diff -Nur gg2-2.2.7.orig/src/plugins/sms/sms_core.h gg2-2.2.7/src/plugins/sms/sms_core.h
+--- gg2-2.2.7.orig/src/plugins/sms/sms_core.h	2005-03-29 14:53:25.000000000 +0000
++++ gg2-2.2.7/src/plugins/sms/sms_core.h	2005-09-01 16:15:02.000000000 +0000
+@@ -1,4 +1,4 @@
+-/* $Id$ */
++/* $Id$ */
+ 
+ /* 
+  * SMS plugin for GNU Gadu 2 
+@@ -32,9 +32,9 @@
+ #define GGADU_SMS_IDEA_URL_SEND		"/sendsms.aspx"
+ 
+ #define GGADU_SMS_ERA_HOST 	"www.eraomnix.pl"
+-#define GGADU_SMS_ERA_URL 	"/sms/do/extern/tinker/free/send"
++#define GGADU_SMS_ERA_URL 	"/msg/api/do/tinker/sponsored"
+ 
+-/* error codes from www.eraomnix.pl/service/gw/bAPIPrv.jsp */
++/* error codes from http://www.eraomnix.pl/pl/between-us/send-sms-mms/sms_gateway_api */
+ #define GGADU_SMS_ERA_ERR_NONE 0
+ #define GGADU_SMS_ERA_ERR_GATEWAY 1
+ #define GGADU_SMS_ERA_ERR_UNAUTH 2
+@@ -43,6 +43,7 @@
+ #define GGADU_SMS_ERA_ERR_LIMIT_EX 7
+ #define GGADU_SMS_ERA_ERR_BAD_RCPT 8
+ #define GGADU_SMS_ERA_ERR_MSG_TOO_LONG 9
++#define GGADU_SMS_ERA_ERR_INSUFF_TOKENS 10
+ 
+ 
+ #define USER_AGENT          "User-Agent: Mozilla/5.0 (X11; U; Linux i686) Gecko/20030313 Galeon/1.3.4\r\n"
+@@ -87,6 +88,7 @@
+ 	ERR_SYNTAX,
+ 	ERR_BAD_RCPT,
+ 	ERR_MSG_TOO_LONG,
++	ERR_INSUFF_TOKENS,
+ 	ERR_UNKNOWN
+ };
+ 
================================================================



More information about the pld-cvs-commit mailing list