diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-01-30 16:42:35 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-01-30 16:42:35 +0100 |
commit | 6c5c3ac2decac75ec3208d47912e67c4e1a33548 (patch) | |
tree | c6cdcc5d76608369da08eb76891c48ffefbb9a48 /src/de/gultsch/chat/services | |
parent | ad11dab6359a1eb2b6921d36117093066999fb96 (diff) |
first draft on xml parser and communication. a long way to go. code definitly not perfect. will refactor asap
Diffstat (limited to 'src/de/gultsch/chat/services')
-rw-r--r-- | src/de/gultsch/chat/services/XmppConnectionService.java | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/de/gultsch/chat/services/XmppConnectionService.java b/src/de/gultsch/chat/services/XmppConnectionService.java index b8a54523..d078714d 100644 --- a/src/de/gultsch/chat/services/XmppConnectionService.java +++ b/src/de/gultsch/chat/services/XmppConnectionService.java @@ -1,22 +1,43 @@ package de.gultsch.chat.services; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.net.UnknownHostException; import java.util.List; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + import de.gultsch.chat.entities.Account; import de.gultsch.chat.entities.Contact; import de.gultsch.chat.entities.Conversation; import de.gultsch.chat.entities.Message; import de.gultsch.chat.persistance.DatabaseBackend; +import de.gultsch.chat.xml.Tag; +import de.gultsch.chat.xml.XmlReader; +import de.gultsch.chat.xmpp.XmppConnection; import android.app.Service; +import android.content.Context; import android.content.Intent; import android.os.Binder; import android.os.IBinder; +import android.os.PowerManager; import android.util.Log; public class XmppConnectionService extends Service { - protected static final String LOGTAG = "xmppConnection"; + protected static final String LOGTAG = "xmppService"; protected DatabaseBackend databaseBackend; + + public long startDate; + + private List<Account> accounts; + + public boolean connectionRunnig = false; private final IBinder mBinder = new XmppConnectionBinder(); @@ -26,9 +47,27 @@ public class XmppConnectionService extends Service { } } + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + Log.d(LOGTAG,"recieved start command. been running for "+((System.currentTimeMillis() - startDate) / 1000)+"s"); + PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); + if (!connectionRunnig) { + for(Account account : accounts) { + Log.d(LOGTAG,"connection wasnt running"); + XmppConnection connection = new XmppConnection(account, pm); + Thread thread = new Thread(connection); + thread.start(); + } + connectionRunnig = true; + } + return START_STICKY; + } + @Override public void onCreate() { databaseBackend = DatabaseBackend.getInstance(getApplicationContext()); + this.accounts = databaseBackend.getAccounts(); + startDate = System.currentTimeMillis(); } @Override |