Execute commands received via SMS on the main service
[fonbot.git] / src / ro / ieval / fonbot / SmsReceiver.java
index b6fce8e6276cd503e97d27993f921c0ad3b27f85..63609bdd9d23c935c884dc78d7f7765a8b4dcb55 100644 (file)
@@ -6,7 +6,6 @@ import static ro.ieval.fonbot.Utils.toNonNull;
 
 import org.eclipse.jdt.annotation.Nullable;
 
-import ro.ieval.fonbot.Address.Protocol;
 import ro.ieval.fonbot.Utils.MessageType;
 import android.content.BroadcastReceiver;
 import android.content.Context;
@@ -69,13 +68,12 @@ public final class SmsReceiver extends BroadcastReceiver {
                        if(lines.length==0 || !lines[0].equals(password))
                                continue;
 
-                       final Address address=new Address(toNonNull(Protocol.SMS), originAddress);//NOPMD variable depends on originAddress
                        for (int i = 1; i < lines.length; i++) {
-                               final String[] words=Utils.shellwords(toNonNull(lines[i]));
-                               final String[] args=new String[words.length-1];//NOPMD variable size depends on words.length
-                               System.arraycopy(words, 1, args, 0, args.length);
-
-                               Utils.processCommand(context, toNonNull(words[0]), args, toNonNull(address));
+                               final Intent process_intent = new Intent(context, FonBotMainService.class);
+                               process_intent.setAction(FonBotMainService.ACTION_PROCESS_COMMAND);
+                               process_intent.putExtra(FonBotMainService.EXTRA_COMMAND_LINE, lines[i]);
+                               process_intent.putExtra(FonBotMainService.EXTRA_SMS_ORIGIN_ADDRESS, originAddress);
+                               context.startService(process_intent);
                        }
 
                        abortBroadcast();
This page took 0.009606 seconds and 4 git commands to generate.