RE: Reporting the number of message parts sent for long messages.

"Angel Fradejas" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi Oded,

For what it's worth, this was my version of the patch. Nothing special,
really. Anyway, now yours it's commited on cvs, so I'll stick to it. A
couple of modifications on my calling applications and I'm done.

This patch is against smsbox.c revision 1.183

Have fun.

Angel Fradejas
Mediafusión España, S.A.
[email protected]
www.mediafusion.es
Tel. +34 91 252 32 00
Fax  +34 91 572 27 08


-----Mensaje original-----
De: Oded Arbel [mailto:[email protected]]
Enviado el: martes 16 de abril de 2002 15:02
Para: Angel Fradejas
CC: Kannel-devel (E-mail)
Asunto: RE: Reporting the number of message parts sent for long
messages.


Can we see your patch too ?
I'm not very good at formatting, so you'r patch may likely be better :-)

--
Oded Arbel
m-Wise Inc.
[email protected]
(972)-67-340014
(972)-9-9581711 (ext: 116)

::..
Get busy living or get busy dying.
	-- Andy Dufresne (Tim Robbins) in The Shawshank Redemption

> -----Original Message-----
> From: Angel Fradejas [mailto:[email protected]]
> Sent: Tuesday, April 16, 2002 1:39 PM
> To: Stipe Tolj
> Cc: Kannel-devel (E-mail)
> Subject: RE: Reporting the number of message parts sent for
> long messages.
>
>
> +1 from me
>
> I had written the same patch for my own use, with a slightly different
> format.
>
> Angel Fradejas.
>
> -----Mensaje original-----
> De: [email protected]
> [mailto:[email protected]]En
> nombre de Stipe Tolj
> Enviado el: martes 16 de abril de 2002 13:35
> CC: Kannel-devel (E-mail)
> Asunto: Re: Reporting the number of message parts sent for long
> messages.
>
>
> > For some purposes (for example - billing) the application
> behind Kannel
> > may need to know how messages Kannel actually sent for each
> message that
> > the application sent to Kannel (as Kannel will split long
> messages into
> > parts).
> > for this prurpose I wrote this hack - it's very simple and not well
> > written, but it allowes the application to analyze the response from
> > smsbox in order to learn how many msg parts the message was
> splitted to.
> >
> > I would like the opinion of the developers on the usefullnes of this
> > behaviour, and how do you think it should be cleaned/standardized.
>
> I'm +1 for this as it does not change send_message() behaviour and
> adds extra information at return.
>
> Any objections for commiting this?
>
> Stipe
>
> [email protected]
> -------------------------------------------------------------------
> Wapme Systems AG
>
> Münsterstr. 248
> 40470 Düsseldorf
>
> Tel: +49-211-74845-0
> Fax: +49-211-74845-299
>
> E-Mail: [email protected]
> Internet: http://www.wapme-systems.de
> -------------------------------------------------------------------
> wapme.net - wherever you are
>
>
>
smsbox.patch (application/octet-stream, 3.6 KB)
Index: gw/smsbox.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsbox.c,v
retrieving revision 1.183
diff -u -r1.183 smsbox.c
--- gw/smsbox.c	10 Apr 2002 18:17:13 -0000	1.183
+++ gw/smsbox.c	17 Apr 2002 07:41:41 -0000
@@ -125,7 +125,7 @@
  * configuration from `trans' to format the message before sending.
  * Return 0 for success, -1 for failure.  Does not destroy the msg.
  */
-static int send_message(URLTranslation *trans, Msg *msg)
+static int send_message(URLTranslation *trans, Msg *msg, int* nparts)
 {
     int max_msgs;
     Octstr *header, *footer, *suffix, *split_chars;
@@ -178,8 +178,11 @@
     	    	     msg_sequence, max_msgs, sms_max_length);
     debug("sms", 0, "message length %ld, sending %ld messages", 
           octstr_len(msg->sms.msgdata), list_len(list));
-    while ((part = list_extract_first(list)) != NULL)
+    if (nparts) *nparts = 0;      
+    while ((part = list_extract_first(list)) != NULL) {
 	write_to_bearerbox(part);
+        if (nparts) (*nparts)++;
+    }
     list_destroy(list, NULL);
     
     return 0;
@@ -706,7 +709,7 @@
 	octstr_destroy(reply_body);
     
 	if (msg->sms.dlr_mask == 0) {
-	    if ( send_message(trans, msg) < 0)
+	    if ( send_message(trans, msg, NULL) < 0)
 		error(0, "failed to send message to phone");
 	}	
 	msg_destroy(msg);
@@ -1184,7 +1187,7 @@
 	    msg->sms.time = time(NULL);	/* set current time */
 	
 	    if (!dreport) {
-	    if (send_message(trans, msg) < 0)
+	    if (send_message(trans, msg, NULL) < 0)
 		error(0, "request_thread: failed");
 	    }
 	}
@@ -1331,6 +1334,7 @@
     List *receiver, *failed_id, *allowed, *denied;
     int no_recv, ret, i;
     long del;
+    int nparts;
 
     /*
      * Multi-cast messages with several receivers in 'to' are handled
@@ -1547,7 +1551,7 @@
         
         msg->sms.receiver = octstr_duplicate(receiv);
         msg->sms.time = time(NULL);
-        ret = send_message(t, msg);
+        ret = send_message(t, msg, &nparts);
 
         if (ret == -1) {
             /* add the receiver to the failed list */
@@ -1577,7 +1581,7 @@
     list_destroy(failed_id, octstr_destroy_item);
     octstr_destroy(newfrom);
     *status = HTTP_ACCEPTED;
-    returnerror = octstr_create("Sent.");
+    returnerror = octstr_format("Sent %d SMS.",nparts);
 
     /* 
      * Append all denied receivers to the returned body in case this is
@@ -1914,6 +1918,7 @@
     URLTranslation *t;
     Msg *msg;
     int ret, ota_type;
+    int nparts;
     
     id = phonenumber = smsc = NULL;
 
@@ -2046,7 +2051,7 @@
     info(0, "%s <%s> <%s>", octstr_get_cstr(sendota_url), 
     	 id ? octstr_get_cstr(id) : "<default>", octstr_get_cstr(phonenumber));
     
-    ret = send_message(t, msg); 
+    ret = send_message(t, msg, &nparts); 
     msg_destroy(msg);
 
     if (ret == -1) {
@@ -2056,7 +2061,7 @@
     }
 
     *status = HTTP_ACCEPTED;
-    return octstr_create("Sent.");
+    return octstr_format("Sent %d SMS.",nparts);
 }
 
 
@@ -2078,6 +2083,7 @@
     Msg *msg;
     long l;
     int r;
+    int nparts;
 
     id = from = to = user = pass = smsc = NULL;
     doc_type = ota_doc = NULL;
@@ -2207,7 +2213,7 @@
         info(0, "%s <%s> <%s>", octstr_get_cstr(sendota_url), 
              id ? octstr_get_cstr(id) : "<default>", octstr_get_cstr(to));
     
-        r = send_message(t, msg); 
+        r = send_message(t, msg, &nparts); 
         msg_destroy(msg);
 
         if (r == -1) {
@@ -2217,7 +2223,7 @@
         }
 
         *status = HTTP_ACCEPTED;
-        ret = octstr_create("Sent.");
+        ret = octstr_format("Sent %d SMS.",nparts);
     }
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.