← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3636: support to send sms from given longnumber

 

------------------------------------------------------------
revno: 3636
committer: Saptarshi <sunbiz@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-05-16 21:04:09 +0200
message:
  support to send sms from given longnumber
added:
  dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/gateway/
  dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/gateway/DhisClickatellGateway.java
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/WEB-INF/classes/log4j.properties
  dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/sms/SmsService.java
  dhis-mobile/dhis-web-sms/src/main/java/org/hisp/dhis/mobile/action/MobileSettingsAction.java
  dhis-mobile/dhis-web-sms/src/main/webapp/dhis-web-sms/mobileSettingsPage.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/WEB-INF/classes/log4j.properties'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/WEB-INF/classes/log4j.properties	2011-04-19 14:37:25 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/WEB-INF/classes/log4j.properties	2011-05-16 19:04:09 +0000
@@ -17,3 +17,4 @@
 # Categories (order: DEBUG, INFO, WARN, ERROR, FATAL)
 log4j.rootCategory = WARN, console 
 log4j.category.org.hisp.dhis = INFO
+log4j.category.smslib = INFO
\ No newline at end of file

=== added directory 'dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/gateway'
=== added file 'dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/gateway/DhisClickatellGateway.java'
--- dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/gateway/DhisClickatellGateway.java	1970-01-01 00:00:00 +0000
+++ dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/gateway/DhisClickatellGateway.java	2011-05-16 19:04:09 +0000
@@ -0,0 +1,14 @@
+package org.hisp.dhis.mobile.gateway;
+
+
+import org.smslib.http.ClickatellHTTPGateway;
+
+public class DhisClickatellGateway extends ClickatellHTTPGateway
+{
+    public DhisClickatellGateway( String gatewayId, String api_id, String username, String password )
+    {
+        super( gatewayId, api_id, username, password );
+    }
+    
+    
+}

=== modified file 'dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/sms/SmsService.java'
--- dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/sms/SmsService.java	2011-05-11 07:26:38 +0000
+++ dhis-mobile/dhis-service-sms/src/main/java/org/hisp/dhis/mobile/sms/SmsService.java	2011-05-16 19:04:09 +0000
@@ -39,6 +39,7 @@
 import java.util.Properties;
 import java.util.Timer;
 import java.util.TimerTask;
+import org.hisp.dhis.mobile.gateway.DhisClickatellGateway;
 import org.hisp.dhis.mobile.sms.utils.Compressor;
 import org.hisp.dhis.mobile.sms.api.SmsInbound;
 import org.hisp.dhis.mobile.sms.api.SmsInboundStoreService;
@@ -60,7 +61,6 @@
 import org.smslib.TimeoutException;
 import org.smslib.helper.Logger;
 import org.smslib.http.BulkSmsHTTPGateway;
-import org.smslib.http.ClickatellHTTPGateway;
 import org.smslib.modem.SerialModemGateway;
 
 /*
@@ -286,6 +286,10 @@
         OutboundMessage outboundMessage = new OutboundMessage( recipient, msg );
         if ( isServiceRunning() )
         {
+            String longNumber = getProperties().getProperty( "provider.longnumber" ).trim();
+            if(longNumber!=null && !longNumber.isEmpty()){
+                outboundMessage.setFrom( longNumber );
+            }
             Service.getInstance().sendMessage( outboundMessage );
             return "MESSAGE SENT SUCCESSFULLY TO: " + recipient;
         } else
@@ -416,6 +420,7 @@
         {
             // Read the messages from SIM memory location, which are Inbound messages
             Service.getInstance().readMessages( msgList, InboundMessage.MessageClasses.ALL );
+            Logger.getInstance().logInfo( "Total messages read at " + Calendar.getInstance().getTime() + " = " + msgList.size(), null, null );
             if ( msgList.size() > 0 )
             {
                 for ( InboundMessage inMsg : msgList )
@@ -487,7 +492,6 @@
                     }
                 }
             }
-            Logger.getInstance().logInfo( "Total messages read at " + Calendar.getInstance().getTime() + " = " + msgList.size(), null, null );
         } catch ( Exception e )
         {
             Logger.getInstance().logError( "SMSServer: reading messages exception!", e, null );
@@ -548,7 +552,7 @@
                         String username = getProperties().getProperty( "clickatell.username" );
                         String password = getProperties().getProperty( "clickatell.password" );
                         String api_id = getProperties().getProperty( "clickatell.api_id" );
-                        ClickatellHTTPGateway gateway = new ClickatellHTTPGateway( "clickatell.http.1", api_id, username, password );
+                        DhisClickatellGateway gateway = new DhisClickatellGateway( "clickatell.http.1", api_id, username, password );
                         gateway.setOutbound( true );
                         gateway.setInbound( true );
                         Service.getInstance().addGateway( gateway );

=== modified file 'dhis-mobile/dhis-web-sms/src/main/java/org/hisp/dhis/mobile/action/MobileSettingsAction.java'
--- dhis-mobile/dhis-web-sms/src/main/java/org/hisp/dhis/mobile/action/MobileSettingsAction.java	2011-05-11 07:26:38 +0000
+++ dhis-mobile/dhis-web-sms/src/main/java/org/hisp/dhis/mobile/action/MobileSettingsAction.java	2011-05-16 19:04:09 +0000
@@ -137,6 +137,18 @@
         props.setProperty( "clickatell.api_id" , clickatellApiId);
     }
     
+    private String longNumber;
+
+    public String getLongNumber()
+    {
+        return props.getProperty( "provider.longnumber" );
+    }
+
+    public void setLongNumber( String longNumber )
+    {
+        props.setProperty( "provider.longnumber" , longNumber);
+    }
+    
     private String port;
 
     public String getPort()
@@ -342,6 +354,7 @@
             props.setProperty( "clickatell.username", "");
             props.setProperty( "clickatell.password", "");
             props.setProperty( "clickatell.api_id", "");
+            props.setProperty( "provider.longnumber", "" );
             props.setProperty( "modem1.port", "COM1" );
             props.setProperty( "modem1.baudrate", "57600" );
             props.setProperty( "modem1.manufacturer", "Generic" );

=== modified file 'dhis-mobile/dhis-web-sms/src/main/webapp/dhis-web-sms/mobileSettingsPage.vm'
--- dhis-mobile/dhis-web-sms/src/main/webapp/dhis-web-sms/mobileSettingsPage.vm	2011-05-11 07:26:38 +0000
+++ dhis-mobile/dhis-web-sms/src/main/webapp/dhis-web-sms/mobileSettingsPage.vm	2011-05-16 19:04:09 +0000
@@ -8,11 +8,13 @@
             #if($gatewayName == "bulksms")
                 <tr><td>Bulksms Username: </td><td><input size="100" name="bulksmsUsername" type="text" value="$!bulksmsUsername" /></td></tr>
                 <tr><td>Bulksms Password: </td><td><input size="100" name="bulksmsPassword" type="text" value="$!bulksmsPassword" /></td></tr>
+                <tr><td>Longnumber: </td><td><input size="100" name="longNumber" type="text" value="$!longNumber" /></td></tr>
             #end
             #if($gatewayName == "clickatell")
                 <tr><td>Clickatell Username: </td><td><input size="100" name="clickatellUsername" type="text" value="$!clickatellUsername" /></td></tr>
                 <tr><td>Clickatell Password: </td><td><input size="100" name="clickatellPassword" type="text" value="$!clickatellPassword" /></td></tr>
                 <tr><td>Clickatell API ID: </td><td><input size="100" name="clickatellApiId" type="text" value="$!clickatellApiId" /></td></tr>
+                <tr><td>Longnumber: </td><td><input size="100" name="longNumber" type="text" value="$!longNumber" /></td></tr>
             #end
             #if($port) <tr><td>Modem Port#: </td><td><input size="100" name="port" type="text" value="$port" /></td></tr>#end
             #if($baudRate) <tr><td>Baudrate: </td><td><input size="100" name="baudRate" type="text" value="$baudRate" /></td></tr>#end