]> iEval git - fonbot.git/blobdiff - src/ro/ieval/fonbot/Utils.java
Remove the SHUTDOWN command
[fonbot.git] / src / ro / ieval / fonbot / Utils.java
index ddb506bfdbabe17d80e81b002742ad2604c5146b..38c34644c8962bfca1f72f8de4644b307314d8aa 100644 (file)
@@ -86,7 +86,7 @@ public final class Utils {
                NEXT, PREV, BATT, CALLLOG, SMSLOG,
                LS, RM, CONTACTS, DISABLE, ENABLE,
                POLL, HANGUP, ANSWER, LAUNCH, DATA,
-               GPS, GLOCATION, REBOOT, SHUTDOWN, NOTIFY
+               GPS, GLOCATION, REBOOT, NOTIFY
        }
 
        /**
@@ -317,7 +317,7 @@ public final class Utils {
                switch(address.protocol){
                case HTTP:
                        new HttpCallExecutableRunnable("/send", toNonNull(Arrays.asList(
-                                       new Header("X-Destination", toNonNull(address.data)))), context, null, message).execute();
+                                       new Header("X-Destination", toNonNull(address.data)))), context, null, true, message).execute();
                        break;
 
                case SMS:
@@ -405,20 +405,30 @@ public final class Utils {
         */
        public static URL getServerURL(final Context context, final String path) throws MalformedURLException{
                final String hostname=PreferenceManager.getDefaultSharedPreferences(context).getString("hostname", "fonbot.ieval.ro");
-               final int port=Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(context).getString("port", "7777"));
+               final int port=Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(context).getString("port", "443"));
                final URL url=new URL("https", hostname, port, path);
                return url;
        }
 
        /**
-        * Poll the server for pending commands.
+        * Poll the server for pending commands. This function must not be called from BroadcastReceivers
         *
         * @param context Context instance
         */
        public static void pollServer(final Context context){
-               new HttpCallExecutableRunnable("/get", null, context, new PollResultCallback(context)).execute();
+               new HttpCallExecutableRunnable("/get", null, context, new PollResultCallback(context), false).execute();
        }
 
+       /**
+        * Poll the server for pending commands from {@link FonBotMainService}. This function should be used from BroadcastReceviers instead of {@link #pollServer}
+        *
+        * @param context Context instance
+        */
+       public static void safePollServer(final Context context){
+               final Intent intent=new Intent(context, FonBotMainService.class);
+               intent.setAction(FonBotMainService.ACTION_TRIGGER_POLL);
+               context.startService(intent);
+       }
        /**
         * Executes a given command
         *
@@ -429,7 +439,7 @@ public final class Utils {
         */
        private static void processCommand(final Context context, final Command cmd,final String[] args,final Address replyTo){
                if(Heavy.isCommandDisabled(context, cmd)){
-                       sendMessage(context, replyTo, command_disabled);
+                       sendMessage(context, replyTo, command_disabled, cmd.toString());
                        return;
                }
 
@@ -993,13 +1003,10 @@ public final class Utils {
                        Heavy.reboot(context, replyTo, args.length==0?null:args[0]);
                        break;
 
-               case SHUTDOWN:
-                       //TODO: implement command
-                       break;
-
                case NOTIFY:
                        if(args.length!=1 && args.length!=3){
                                Heavy.help(context, replyTo, toNonNull(Command.NOTIFY));
+                               return;
                        }
 
                        final int id;
This page took 0.026553 seconds and 4 git commands to generate.