2014-01-24 01:04:05 +00:00
|
|
|
package de.gultsch.chat.services;
|
|
|
|
|
2014-01-25 18:33:12 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import de.gultsch.chat.entities.Conversation;
|
|
|
|
import de.gultsch.chat.entities.Message;
|
|
|
|
import de.gultsch.chat.persistance.DatabaseBackend;
|
2014-01-24 01:04:05 +00:00
|
|
|
import android.app.Service;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Binder;
|
|
|
|
import android.os.IBinder;
|
2014-01-25 18:33:12 +00:00
|
|
|
import android.util.Log;
|
2014-01-24 01:04:05 +00:00
|
|
|
|
|
|
|
public class XmppConnectionService extends Service {
|
2014-01-25 18:33:12 +00:00
|
|
|
|
|
|
|
protected static final String LOGTAG = "xmppConnection";
|
|
|
|
protected DatabaseBackend databaseBackend;
|
2014-01-24 01:04:05 +00:00
|
|
|
|
|
|
|
private final IBinder mBinder = new XmppConnectionBinder();
|
|
|
|
|
|
|
|
public class XmppConnectionBinder extends Binder {
|
2014-01-25 18:33:12 +00:00
|
|
|
public XmppConnectionService getService() {
|
|
|
|
return XmppConnectionService.this;
|
2014-01-24 01:04:05 +00:00
|
|
|
}
|
|
|
|
}
|
2014-01-25 18:33:12 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate() {
|
|
|
|
databaseBackend = DatabaseBackend.getInstance(getApplicationContext());
|
|
|
|
}
|
|
|
|
|
2014-01-24 01:04:05 +00:00
|
|
|
@Override
|
|
|
|
public IBinder onBind(Intent intent) {
|
|
|
|
return mBinder;
|
|
|
|
}
|
2014-01-25 18:33:12 +00:00
|
|
|
|
|
|
|
public void sendMessage(Message message) {
|
|
|
|
Log.d(LOGTAG,"sending message");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addConversation(Conversation conversation) {
|
|
|
|
databaseBackend.addConversation(conversation);
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Conversation> getConversations(int status) {
|
|
|
|
return databaseBackend.getConversations(status);
|
|
|
|
}
|
2014-01-24 01:04:05 +00:00
|
|
|
|
|
|
|
}
|