# HG changeset patch # User Vincent V. # Date 1329866950 -3600 # Node ID 5801f1f5f0bd4d2da0e2242423eb4627d6e08b5e # Parent 53e19596d22c58ce40a24b7638a47edc3748cf53 muc message available diff -r 53e19596d22c -r 5801f1f5f0bd AndroidManifest.xml --- a/AndroidManifest.xml Tue Feb 21 20:10:27 2012 +0100 +++ b/AndroidManifest.xml Wed Feb 22 00:29:10 2012 +0100 @@ -205,6 +205,7 @@ + diff -r 53e19596d22c -r 5801f1f5f0bd src/com/beem/project/beem/BeemIntent.java --- a/src/com/beem/project/beem/BeemIntent.java Tue Feb 21 20:10:27 2012 +0100 +++ b/src/com/beem/project/beem/BeemIntent.java Wed Feb 22 00:29:10 2012 +0100 @@ -58,9 +58,11 @@ public static final String ACTION_ADD_CONTACT = "com.beem.project.beem.intent.action.ADD_CONTACT"; public static final String ACTION_CHANGE_STATUS = "com.beem.project.beem.intent.action.CHANGE_STATUS"; - + public static final String ACTION_MUC_JOIN = "com.beem.project.beem.intent.action.MUC_JOIN"; + public static final String ACTION_MUC_SEND_MESSAGE = "com.beem.project.beem.intent.action.MUC_SEND_MESSAGE"; + /* Broadcast Receiver's action */ public static final String ACTION_CONNECTED = "com.beem.project.beem.intent.action.CONNECTED"; diff -r 53e19596d22c -r 5801f1f5f0bd src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Tue Feb 21 20:10:27 2012 +0100 +++ b/src/com/beem/project/beem/BeemService.java Wed Feb 22 00:29:10 2012 +0100 @@ -117,8 +117,7 @@ private static final int MESSAGE_ADD_CONTACT = 0x5; private static final int MESSAGE_CHANGE_STATUS = 0x7; private static final int MESSAGE_MUC_JOIN = 0x8; - - //Next = 0x9; + private static final int MESSAGE_MUC_SEND_MSG = 0x9; private Map mConnection = new HashMap(); private Map mBeemConnection = new HashMap(); @@ -441,6 +440,8 @@ msg = mHandler.obtainMessage(MESSAGE_CHANGE_STATUS, intent.getExtras()); } else if (BeemIntent.ACTION_MUC_JOIN.equals(action)) { msg = mHandler.obtainMessage(MESSAGE_MUC_JOIN, intent.getExtras()); + } else if (BeemIntent.ACTION_MUC_SEND_MESSAGE.equals(action)) { + msg = mHandler.obtainMessage(MESSAGE_MUC_SEND_MSG, intent.getExtras()); } else { Log.w(TAG, "Unknown intent " + intent); } @@ -541,6 +542,15 @@ Log.e(TAG, "MUC Join Problem", e); } break; + case MESSAGE_MUC_SEND_MSG: + MultiUserChat mucmsg = new MultiUserChat(connection.getAdaptee(), b.getString(BeemIntent.EXTRA_JID)); + try { + Log.e(TAG, "-" + b.getString(BeemIntent.EXTRA_MESSAGE)); + mucmsg.sendMessage(b.getString(BeemIntent.EXTRA_MESSAGE)); + } catch (XMPPException e) { + Log.e(TAG, "Error send message to muc", e); + } + break; default: Log.w(TAG, "Unknown message " + msg); } diff -r 53e19596d22c -r 5801f1f5f0bd src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Tue Feb 21 20:10:27 2012 +0100 +++ b/src/com/beem/project/beem/ui/ContactList.java Wed Feb 22 00:29:10 2012 +0100 @@ -577,6 +577,7 @@ Intent i = new Intent(ContactList.this, MucChat.class); i.setData(Uri.parse("imto://jabber/" + jid)); + i.putExtra(BeemIntent.EXTRA_ACCOUNT, mAccountName); startActivity(i); } } diff -r 53e19596d22c -r 5801f1f5f0bd src/com/beem/project/beem/ui/MucChat.java --- a/src/com/beem/project/beem/ui/MucChat.java Tue Feb 21 20:10:27 2012 +0100 +++ b/src/com/beem/project/beem/ui/MucChat.java Wed Feb 22 00:29:10 2012 +0100 @@ -54,7 +54,6 @@ import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; -import android.provider.ContactsContract.RawContacts; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -100,17 +99,7 @@ Uri contactURI = getIntent().getData(); mjid = contactURI.getPathSegments().get(0); - - Cursor cursorAccount = getContentResolver().query(RawContacts.CONTENT_URI, - new String[] { RawContacts._ID, RawContacts.ACCOUNT_NAME }, RawContacts.SOURCE_ID + "=?", - new String[] { mjid }, null); - - if (cursorAccount.getCount() == 1) { - cursorAccount.moveToFirst(); - mAccount = cursorAccount.getString(cursorAccount.getColumnIndex(RawContacts.ACCOUNT_NAME)); - } else if (cursorAccount.getCount() > 1) { - // TODO : get account from jid. if multi account propose select - } + mAccount = getIntent().getExtras().getString(BeemIntent.EXTRA_ACCOUNT); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); boolean isCompact = settings.getBoolean("settings_chat_compact_key", false); @@ -174,8 +163,8 @@ private void sendMessage() { EditText inputField = (EditText) findViewById(R.id.chat_input); final String inputContent = inputField.getText().toString(); - - Intent intent = new Intent(BeemIntent.ACTION_SEND_MESSAGE); + Log.e(TAG, "+" + inputContent); + Intent intent = new Intent(BeemIntent.ACTION_MUC_SEND_MESSAGE); intent.putExtra(BeemIntent.EXTRA_ACCOUNT, mAccount); intent.putExtra(BeemIntent.EXTRA_JID, mjid); intent.putExtra(BeemIntent.EXTRA_MESSAGE, inputContent);