ctrl k
  • tigase-mobile-lib/src/org/tigase/mobile/MultiJaxmpp.java
    ■ ■ ■ ■ ■ ■
    skipped 26 lines
    27 27   
    28 28   private final Object data;
    29 29   
    30  - @Override
    31  - public int hashCode() {
    32  - return data.hashCode();
    33  - }
    34  - 
    35  - @Override
    36  - public boolean equals(Object o) {
    37  - return data.equals(o);
     30 + public ChatWrapper(Chat chat) {
     31 + this.data = chat;
    38 32   }
    39 33   
    40 34   public ChatWrapper(Room room) {
    41 35   this.data = room;
    42 36   }
    43 37   
    44  - public ChatWrapper(Chat chat) {
    45  - this.data = chat;
    46  - }
    47  - 
    48  - public boolean isChat() {
    49  - return data instanceof Chat;
    50  - }
    51  - 
    52  - public boolean isRoom() {
    53  - return data instanceof Room;
     38 + @Override
     39 + public boolean equals(Object o) {
     40 + if (o instanceof ChatWrapper) {
     41 + return data.equals(((ChatWrapper) o).data);
     42 + } else
     43 + return data.equals(o);
    54 44   }
    55 45   
    56 46   public Chat getChat() {
    skipped 9 lines
    66 56   else
    67 57   return null;
    68 58   }
     59 + 
     60 + @Override
     61 + public int hashCode() {
     62 + return data.hashCode();
     63 + }
     64 + 
     65 + public boolean isChat() {
     66 + return data instanceof Chat;
     67 + }
     68 + 
     69 + public boolean isRoom() {
     70 + return data instanceof Room;
     71 + }
    69 72   }
    70 73   
    71 74   private final ArrayList<ChatWrapper> chats = new ArrayList<ChatWrapper>();
    skipped 12 lines
    84 87   if (be.getType() == MessageModule.ChatCreated) {
    85 88   chats.add(new ChatWrapper(((MessageEvent) be).getChat()));
    86 89   } else if (be.getType() == MessageModule.ChatClosed) {
    87  - chats.remove(((MessageEvent) be).getChat());
     90 + chats.remove(new ChatWrapper(((MessageEvent) be).getChat()));
    88 91   } else if (be.getType() == MucModule.RoomClosed) {
    89 92   chats.remove(new ChatWrapper(((MucEvent) be).getRoom()));
    90 93   } else if (be.getType() == MucModule.YouJoined) {
    skipped 71 lines
  • tigase-mobile-lib/src/org/tigase/mobile/TigaseMobileMessengerActivity.java
    ■ ■ ■ ■ ■ ■
    skipped 27 lines
    28 28  import tigase.jaxmpp.core.client.xmpp.modules.chat.Chat;
    29 29  import tigase.jaxmpp.core.client.xmpp.modules.chat.MessageModule;
    30 30  import tigase.jaxmpp.core.client.xmpp.modules.chat.MessageModule.MessageEvent;
     31 +import tigase.jaxmpp.core.client.xmpp.modules.muc.MucModule;
     32 +import tigase.jaxmpp.core.client.xmpp.modules.muc.Room;
    31 33  import tigase.jaxmpp.core.client.xmpp.modules.roster.RosterItem;
    32 34  import tigase.jaxmpp.j2se.Jaxmpp;
    33 35  import android.accounts.Account;
    skipped 228 lines
    262 264   Uri selected = data.getData();
    263 265   String mimetype = data.getType();
    264 266   final int p = this.currentPage;
    265  - Chat chat = getChatByPageIndex(p);
     267 + ChatWrapper chatW = getChatByPageIndex(p);
     268 + Chat chat = chatW.getChat();
     269 + if (chat == null)
     270 + return;
    266 271   RosterItem ri = chat.getSessionObject().getRoster().get(chat.getJid().getBareJid());
    267 272   JID jid = chat.getJid();
    268 273   if (jid.getResource() == null) {
    skipped 132 lines
    401 406   
    402 407   } else {
    403 408   int idx = i - (!isXLarge() ? 2 : 1);
    404  - final Chat chat = getChatList().get(idx);
    405  - return ChatHistoryFragment.newInstance(chat.getSessionObject().getUserBareJid().toString(), chat.getId(),
    406  - idx);
     409 + final ChatWrapper wrapper = getChatList().get(idx);
     410 + if (wrapper.isChat()) {
     411 + return ChatHistoryFragment.newInstance(
     412 + wrapper.getChat().getSessionObject().getUserBareJid().toString(), wrapper.getChat().getId(),
     413 + idx);
     414 + } else {
     415 + Room room = wrapper.getRoom();
     416 + // TODO
     417 + return null;
     418 + }
    407 419   }
    408 420   }
    409 421   
    skipped 30 lines
    440 452   else if (index == 1)
    441 453   return "android:switcher:" + viewId + ":roster";
    442 454   else {
    443  - Chat chat = getChatByPageIndex(index);
    444  - String name = "android:switcher:" + viewId + ":" + chat;
     455 + ChatWrapper wrapper = getChatByPageIndex(index);
     456 + String name = "android:switcher:" + viewId + ":" + wrapper;
    445 457   if (DEBUG)
    446 458   Log.d(TAG, "Chat page name: " + name);
    447 459   return name;
    skipped 177 lines
    625 637   this.startActivityForResult(chatListActivity, REQUEST_CHAT);
    626 638   } else if (item.getItemId() == R.id.closeChatButton) {
    627 639   final int p = this.currentPage;
    628  - Chat chat = getChatByPageIndex(p);
    629  - final Jaxmpp jaxmpp = ((MessengerApplication) getApplicationContext()).getMultiJaxmpp().get(chat.getSessionObject());
    630  - final AbstractChatManager cm = jaxmpp.getModulesManager().getModule(MessageModule.class).getChatManager();
    631  - try {
    632  - cm.close(chat);
    633  - if (DEBUG)
    634  - Log.i(TAG, "Chat with " + chat.getJid() + " (" + chat.getId() + ") closed");
    635  - } catch (JaxmppException e) {
    636  - Log.w(TAG, "Chat close problem!", e);
     640 + ChatWrapper wrapper = getChatByPageIndex(p);
     641 + if (wrapper.isChat()) {
     642 + Chat chat = wrapper.getChat();
     643 + final Jaxmpp jaxmpp = ((MessengerApplication) getApplicationContext()).getMultiJaxmpp().get(
     644 + chat.getSessionObject());
     645 + final AbstractChatManager cm = jaxmpp.getModulesManager().getModule(MessageModule.class).getChatManager();
     646 + try {
     647 + cm.close(chat);
     648 + if (DEBUG)
     649 + Log.i(TAG, "Chat with " + chat.getJid() + " (" + chat.getId() + ") closed");
     650 + } catch (JaxmppException e) {
     651 + Log.w(TAG, "Chat close problem!", e);
     652 + }
     653 + } else {
     654 + Room room = wrapper.getRoom();
     655 + final Jaxmpp jaxmpp = ((MessengerApplication) getApplicationContext()).getMultiJaxmpp().get(
     656 + room.getSessionObject());
     657 + final MucModule cm = jaxmpp.getModulesManager().getModule(MucModule.class);
     658 + try {
     659 + cm.leave(room);
     660 + } catch (JaxmppException e) {
     661 + Log.w(TAG, "Chat close problem!", e);
     662 + }
    637 663   }
     664 + 
    638 665   viewPager.setCurrentItem(1);
    639 666   } else if (item.getItemId() == R.id.shareImageButton) {
    640 667   final int p = this.currentPage;
    641  - Chat chat = getChatByPageIndex(p);
     668 + Chat chat = getChatByPageIndex(p).getChat();
    642 669   Log.v(TAG, "share selected for = " + chat.getJid().toString());
    643 670   Intent pickerIntent = new Intent(Intent.ACTION_PICK);
    644 671   pickerIntent.setType("image/*");
    skipped 1 lines
    646 673   startActivityForResult(pickerIntent, SELECT_FOR_SHARE);
    647 674   } else if (item.getItemId() == R.id.shareVideoButton) {
    648 675   final int p = this.currentPage;
    649  - Chat chat = getChatByPageIndex(p);
     676 + Chat chat = getChatByPageIndex(p).getChat();
    650 677   Log.v(TAG, "share selected for = " + chat.getJid().toString());
    651 678   Intent pickerIntent = new Intent(Intent.ACTION_PICK);
    652 679   pickerIntent.setType("video/*");
    skipped 60 lines
    713 740   
    714 741   // Share button support
    715 742   MenuItem share = menu.findItem(R.id.shareButton);
    716  - Chat chat = getChatByPageIndex(this.currentPage);
     743 + Chat chat = getChatByPageIndex(this.currentPage).getChat();
    717 744   if (chat == null)
    718 745   return false;
    719 746   final Jaxmpp jaxmpp = ((MessengerApplication) TigaseMobileMessengerActivity.this.getApplicationContext()).getMultiJaxmpp().get(
    skipped 118 lines
  • tigase-mobile-lib/src/org/tigase/mobile/chat/ChatHistoryFragment.java
    ■ ■ ■ ■ ■ ■
    skipped 4 lines
    5 5   
    6 6  import org.tigase.mobile.MessengerApplication;
    7 7  import org.tigase.mobile.MultiJaxmpp;
     8 +import org.tigase.mobile.MultiJaxmpp.ChatWrapper;
    8 9  import org.tigase.mobile.R;
    9 10  import org.tigase.mobile.RosterDisplayTools;
    10 11  import org.tigase.mobile.db.ChatTableMetaData;
    skipped 133 lines
    144 145   
    145 146   if (getArguments() != null) {
    146 147   int idx = getArguments().getInt("page");
    147  - List<Chat> chats = ((MessengerApplication) getActivity().getApplication()).getMultiJaxmpp().getChats();
     148 + List<ChatWrapper> chats = ((MessengerApplication) getActivity().getApplication()).getMultiJaxmpp().getChats();
    148 149   if (idx < chats.size()) {
    149  - Chat ch = chats.get(idx);
     150 + Chat ch = chats.get(idx).getChat();
    150 151   setChatId(ch.getSessionObject().getUserBareJid(), ch.getId());
    151 152   } else {
    152 153   Log.v(TAG, "got request for page = " + idx + " but we have only " + chats.size() + " open");
    skipped 85 lines
    238 239   @Override
    239 240   public void onResume() {
    240 241   final ListView lv = (ListView) layout.findViewById(R.id.chat_conversation_history);
    241  - if (((ChatAdapter)lv.getAdapter()).getCursor().isClosed()) {
    242  - ((ChatAdapter)lv.getAdapter()).swapCursor(getCursor());
     242 + if (((ChatAdapter) lv.getAdapter()).getCursor().isClosed()) {
     243 + ((ChatAdapter) lv.getAdapter()).swapCursor(getCursor());
    243 244   }
    244 245   
    245 246   super.onResume();
    skipped 46 lines
    292 293   private void setChatId(final BareJID account, final long chatId) {
    293 294   MultiJaxmpp multi = ((MessengerApplication) getActivity().getApplicationContext()).getMultiJaxmpp();
    294 295   
    295  - List<Chat> l = multi.getChats();
     296 + List<ChatWrapper> l = multi.getChats();
    296 297   for (int i = 0; i < l.size(); i++) {
    297  - Chat c = l.get(i);
    298  - if (c.getId() == chatId) {
    299  - this.chat = c;
     298 + ChatWrapper c = l.get(i);
     299 + if (c.isChat() && c.getChat().getId() == chatId) {
     300 + this.chat = c.getChat();
    300 301   if (DEBUG)
    301  - Log.d(TAG, "Found chat with " + c.getJid() + " (id=" + chatId + ")");
     302 + Log.d(TAG, "Found chat with " + chat.getJid() + " (id=" + chatId + ")");
    302 303   
    303 304   return;
    304 305   }
    skipped 1 lines
    306 307   
    307 308   String ids = "";
    308 309   for (int i = 0; i < l.size(); i++) {
    309  - Chat c = l.get(i);
    310  - ids += c.getId() + " ";
     310 + ChatWrapper c = l.get(i);
     311 + ids += c + " ";
    311 312   }
    312 313   throw new RuntimeException("Chat (id:" + chatId + ", account:" + account + ") not found! Available ids=" + ids);
    313 314   }
    skipped 59 lines
  • tigase-mobile-lib/src/org/tigase/mobile/chatlist/ChatListActivity.java
    ■ ■ ■ ■ ■ ■
    skipped 3 lines
    4 4   
    5 5  import org.tigase.mobile.MessengerApplication;
    6 6  import org.tigase.mobile.MultiJaxmpp;
     7 +import org.tigase.mobile.MultiJaxmpp.ChatWrapper;
    7 8  import org.tigase.mobile.R;
    8 9  import org.tigase.mobile.RosterDisplayTools;
    9 10  import org.tigase.mobile.db.RosterTableMetaData;
    skipped 1 lines
    11 12  import org.tigase.mobile.roster.CPresence;
    12 13   
    13 14  import tigase.jaxmpp.core.client.xmpp.modules.chat.Chat;
     15 +import tigase.jaxmpp.core.client.xmpp.modules.muc.Room;
    14 16  import tigase.jaxmpp.core.client.xmpp.modules.roster.RosterItem;
    15 17  import tigase.jaxmpp.core.client.xmpp.modules.roster.RosterStore;
    16 18  import android.app.Activity;
    skipped 19 lines
    36 38   
    37 39   private class ImageAdapter extends BaseAdapter {
    38 40   
    39  - private final ArrayList<Chat> chats = new ArrayList<Chat>();
     41 + private final ArrayList<ChatWrapper> chats = new ArrayList<ChatWrapper>();
    40 42   
    41 43   private Context mContext;
    42 44   
    skipped 23 lines
    66 68   
    67 69   @Override
    68 70   public long getItemId(int position) {
    69  - return this.chats.get(position).getId();
     71 + // XXX
     72 + return this.chats.get(position).hashCode();
    70 73   }
    71 74   
    72 75   @Override
    skipped 12 lines
    85 88   imageView = convertView;
    86 89   }
    87 90   
    88  - Chat chat = this.chats.get(position);
     91 + final TextView tv = (TextView) imageView.findViewById(R.id.chat_list_item_name);
     92 + final ImageView avatar = (ImageView) imageView.findViewById(R.id.imageView1);
     93 + final ImageView itemPresence = (ImageView) imageView.findViewById(R.id.imageView2);
    89 94   
    90  - final Cursor cursor = getContentResolver().query(
    91  - Uri.parse(RosterProvider.CONTENT_URI + "/" + chat.getJid().getBareJid()), null, null, null, null);
    92  - byte[] avatarData = null;
    93  - try {
    94  - cursor.moveToNext();
    95  - avatarData = cursor.getBlob(cursor.getColumnIndex(RosterTableMetaData.FIELD_AVATAR));
    96  - } catch (Exception ex) {
    97  - Log.v("ChatListActivity", "no avatar for " + chat.getJid().getBareJid().toString());
    98  - } finally {
    99  - cursor.close();
    100  - }
     95 + ChatWrapper wrapper = this.chats.get(position);
     96 + if (wrapper.isChat()) {
     97 + Chat chat = wrapper.getChat();
    101 98   
    102  - String x;
    103  - RosterStore roster = multi.get(chat.getSessionObject()).getRoster();
    104  - RosterItem ri = roster.get(chat.getJid().getBareJid());
    105  - if (ri == null)
    106  - x = chat.getJid().toString();
    107  - else
    108  - x = rdt.getDisplayName(ri);
     99 + final Cursor cursor = getContentResolver().query(
     100 + Uri.parse(RosterProvider.CONTENT_URI + "/" + chat.getJid().getBareJid()), null, null, null, null);
     101 + byte[] avatarData = null;
     102 + try {
     103 + cursor.moveToNext();
     104 + avatarData = cursor.getBlob(cursor.getColumnIndex(RosterTableMetaData.FIELD_AVATAR));
     105 + } catch (Exception ex) {
     106 + Log.v("ChatListActivity", "no avatar for " + chat.getJid().getBareJid().toString());
     107 + } finally {
     108 + cursor.close();
     109 + }
    109 110   
    110  - final CPresence cp = rdt.getShowOf(chat.getSessionObject(), chat.getJid());
     111 + String x;
     112 + RosterStore roster = multi.get(chat.getSessionObject()).getRoster();
     113 + RosterItem ri = roster.get(chat.getJid().getBareJid());
     114 + if (ri == null)
     115 + x = chat.getJid().toString();
     116 + else
     117 + x = rdt.getDisplayName(ri);
    111 118   
    112  - ImageView itemPresence = (ImageView) imageView.findViewById(R.id.imageView2);
    113  - if (cp == null)
    114  - itemPresence.setImageResource(R.drawable.user_offline);
    115  - else
    116  - switch (cp) {
    117  - case chat:
    118  - case online:
    119  - itemPresence.setImageResource(R.drawable.user_available);
    120  - break;
    121  - case away:
    122  - itemPresence.setImageResource(R.drawable.user_away);
    123  - break;
    124  - case xa:
    125  - itemPresence.setImageResource(R.drawable.user_extended_away);
    126  - break;
    127  - case dnd:
    128  - itemPresence.setImageResource(R.drawable.user_busy);
    129  - break;
    130  - default:
     119 + final CPresence cp = rdt.getShowOf(chat.getSessionObject(), chat.getJid());
     120 + 
     121 + if (cp == null)
    131 122   itemPresence.setImageResource(R.drawable.user_offline);
    132  - break;
    133  - }
     123 + else
     124 + switch (cp) {
     125 + case chat:
     126 + case online:
     127 + itemPresence.setImageResource(R.drawable.user_available);
     128 + break;
     129 + case away:
     130 + itemPresence.setImageResource(R.drawable.user_away);
     131 + break;
     132 + case xa:
     133 + itemPresence.setImageResource(R.drawable.user_extended_away);
     134 + break;
     135 + case dnd:
     136 + itemPresence.setImageResource(R.drawable.user_busy);
     137 + break;
     138 + default:
     139 + itemPresence.setImageResource(R.drawable.user_offline);
     140 + break;
     141 + }
    134 142   
    135  - TextView tv = (TextView) imageView.findViewById(R.id.chat_list_item_name);
    136  - tv.setText(x);
     143 + tv.setText(x);
    137 144   
    138  - ImageView avatar = (ImageView) imageView.findViewById(R.id.imageView1);
    139  - 
    140  - if (avatarData != null) {
    141  - Bitmap bmp = BitmapFactory.decodeByteArray(avatarData, 0, avatarData.length);
    142  - avatar.setImageBitmap(bmp);
     145 + if (avatarData != null) {
     146 + Bitmap bmp = BitmapFactory.decodeByteArray(avatarData, 0, avatarData.length);
     147 + avatar.setImageBitmap(bmp);
     148 + } else {
     149 + avatar.setImageResource(R.drawable.user_avatar);
     150 + }
    143 151   } else {
    144  - avatar.setImageResource(R.drawable.user_avatar);
     152 + Room room = wrapper.getRoom();
     153 + tv.setText(room.getRoomJid().toString());
    145 154   }
    146 155   
    147 156   return imageView;
    skipped 13 lines
    161 170   
    162 171   @Override
    163 172   public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    164  - Chat chat = (Chat) parent.getItemAtPosition(position);
     173 + ChatWrapper wrapper = (ChatWrapper) parent.getItemAtPosition(position);
    165 174   Intent result = new Intent();
    166  - result.putExtra("jid", chat.getJid().toString());
    167  - result.putExtra("chatId", chat.getId());
     175 + if (wrapper.isChat()) {
     176 + result.putExtra("jid", wrapper.getChat().getJid().toString());
     177 + result.putExtra("chatId", wrapper.getChat().getId());
     178 + } else {
     179 + result.putExtra("room", wrapper.getRoom().getRoomJid().toString());
     180 + result.putExtra("roomId", wrapper.getRoom().getId());
     181 + }
    168 182   setResult(Activity.RESULT_OK, result);
    169 183   finish();
    170 184   }
    skipped 7 lines
  • tigase-mobile-lib/src/org/tigase/mobile/db/OpenMUCTableMetaData.java
    ■ ■ ■ ■ ■ ■
    skipped 7 lines
    8 8   
    9 9   public static final String FIELD_ID = "_id";
    10 10   
    11  - public static final String FIELD_ROOM_JID = "room_jid";
    12  - 
    13  - public static final String FIELD_USERNAME = "username";
    14  - 
    15 11   public static final String FIELD_PASSWORD = "password";
    16 12   
     13 + public static final String FIELD_ROOM_JID = "room_jid";
     14 + 
    17 15   public static final String FIELD_TIMESTAMP = "timestamp";
     16 + 
     17 + public static final String FIELD_USERNAME = "username";
    18 18   
    19 19   public static final String TABLE_NAME = "open_muc";
    20 20   
    skipped 2 lines
  • tigase-mobile-lib/src/org/tigase/mobile/filetransfer/AndroidFileTransferUtility.java
    ■ ■ ■ ■ ■
    skipped 130 lines
    131 131   // it should not happen
    132 132   Log.v(TAG, "no file for uri = " + uri.toString());
    133 133   }
    134  - // we are using managedQuery so we are not allowed to close this cursor!
    135  - //cursor.close();
     134 + // we are using managedQuery so we are not allowed to close this
     135 + // cursor!
     136 + // cursor.close();
    136 137   } catch (Exception ex) {
    137 138   Log.e(TAG, "should not happen", ex);
    138 139   }
    skipped 58 lines
  • tigase-mobile-lib/src/org/tigase/mobile/preferences/AccountAdvancedPreferencesActivity.java
    Content is identical
  • tigase-mobile-lib/src/org/tigase/mobile/roster/RosterFragment.java
    Content is identical
  • tigase-mobile-lib/src/org/tigase/mobile/service/JaxmppService.java
    ■ ■ ■ ■ ■ ■
    skipped 190 lines
    191 191   
    192 192   public static final int FILE_TRANSFER_NOTIFICATION_ID = 132009;
    193 193   
     194 + private final static Set<SessionObject> locked = new HashSet<SessionObject>();
     195 + 
    194 196   public static final String MOBILE_OPTIMIZATIONS_ENABLED = Features.MOBILE_V1 + "#enabled";
    195 197   
    196 198   public static final String MOBILE_OPTIMIZATIONS_QUEUE_TIMEOUT = Features.MOBILE_V1 + "#presence_queue_timeout";
    skipped 53 lines
    250 252   public static boolean isServiceActive() {
    251 253   return serviceActive;
    252 254   }
    253  - 
    254  - private final static Set<SessionObject> locked = new HashSet<SessionObject>();
    255 255   
    256 256   private static void lock(SessionObject jaxmpp, boolean value) {
    257 257   synchronized (locked) {
    skipped 1459 lines
Please wait...
Page is in error, reload to recover