private void MenuItem_Tap_AddUser(object sender, System.Windows.Input.GestureEventArgs e) { if (!NetworkInterface.GetIsNetworkAvailable()) { MessageBoxResult result = MessageBox.Show(AppResources.Please_Try_Again_Txt, AppResources.No_Network_Txt, MessageBoxButton.OK); return; } ListBoxItem selectedListBoxItem = this.groupChatParticipants.ItemContainerGenerator.ContainerFromItem((sender as MenuItem).DataContext) as ListBoxItem; if (selectedListBoxItem == null) { return; } gp_obj = selectedListBoxItem.DataContext as GroupParticipant; if (gp_obj == null) { return; } if (!gp_obj.Msisdn.Contains(gp_obj.Name)) // shows name is already stored so return { return; } ContactInfo ci = UsersTableUtils.getContactInfoFromMSISDN(gp_obj.Msisdn); if (ci != null) { return; } ContactUtils.saveContact(gp_obj.Msisdn, new ContactUtils.contactSearch_Callback(saveContactTask_Completed)); }
public GroupParticipant getGroupParticipant(string defaultName, string msisdn, string grpId) { if (grpId == null) { return(null); } if (groupCache.ContainsKey(grpId)) { List <GroupParticipant> l = groupCache[grpId]; for (int i = 0; i < l.Count; i++) { if (l[i].Msisdn == msisdn) { return(l[i]); } } } ContactInfo cInfo = UsersTableUtils.getContactInfoFromMSISDN(msisdn); GroupParticipant gp = new GroupParticipant(grpId, cInfo != null ? cInfo.Name : string.IsNullOrWhiteSpace(defaultName) ? msisdn : defaultName, msisdn, cInfo != null ? cInfo.OnHike : true); if (groupCache.ContainsKey(grpId)) { groupCache[grpId].Add(gp); return(gp); } List <GroupParticipant> ll = new List <GroupParticipant>(); ll.Add(gp); groupCache.Add(grpId, ll); return(gp); }
private void btnGetSelected_Tap(object sender, System.Windows.Input.GestureEventArgs e) { groupChatParticipants.SelectedIndex = -1; gp_obj = (sender as ListBox).SelectedItem as GroupParticipant; if (gp_obj == null) { return; } if (!gp_obj.Msisdn.Contains(gp_obj.Name)) // shows name is already stored so return { return; } ContactInfo ci = UsersTableUtils.getContactInfoFromMSISDN(gp_obj.Msisdn); if (ci != null) { return; } ContactUtils.saveContact(gp_obj.Msisdn, new ContactUtils.contactSearch_Callback(saveContactTask_Completed)); }
private void LoadMessages() { List <Conversation> conversationList = ConversationTableUtils.getAllConversations(); if (conversationList == null) { return; } for (int i = 0; i < conversationList.Count; i++) { Conversation conv = conversationList[i]; ConvMessage lastMessage = MessagesTableUtils.getLastMessageForMsisdn(conv.Msisdn); // why we are not getting only lastmsg as string ContactInfo contact = UsersTableUtils.getContactInfoFromMSISDN(conv.Msisdn); Thumbnails thumbnail = MiscDBUtil.getThumbNailForMSisdn(conv.Msisdn); ConversationListObject mObj = new ConversationListObject((contact == null) ? conv.Msisdn : contact.Msisdn, (contact == null) ? conv.Msisdn : contact.Name, lastMessage.Message, (contact == null) ? conv.OnHike : contact.OnHike, TimeUtils.getTimeString(lastMessage.Timestamp), thumbnail == null ? null : thumbnail.Avatar); convMap.Add(conv.Msisdn, mObj); App.ViewModel.MessageListPageCollection.Add(mObj); } }
public void onEventReceived(string type, object obj) { if (HikePubSub.MESSAGE_RECEIVED == type || HikePubSub.SEND_NEW_MSG == type) { ConvMessage convMessage = (ConvMessage)obj; ConversationListObject mObj; bool isNewConversation = false; /*This is used to avoid cross thread invokation exception*/ if (convMap.ContainsKey(convMessage.Msisdn)) { mObj = convMap[convMessage.Msisdn]; mObj.LastMessage = convMessage.Message; mObj.TimeStamp = TimeUtils.getTimeString(convMessage.Timestamp); Deployment.Current.Dispatcher.BeginInvoke(() => { App.ViewModel.MessageListPageCollection.Remove(mObj); }); } else { ContactInfo contact = UsersTableUtils.getContactInfoFromMSISDN(convMessage.Msisdn); Thumbnails thumbnail = MiscDBUtil.getThumbNailForMSisdn(convMessage.Msisdn); mObj = new ConversationListObject(convMessage.Msisdn, contact == null ? convMessage.Msisdn : contact.Name, convMessage.Message, contact == null ? !convMessage.IsSms : contact.OnHike, TimeUtils.getTimeString(convMessage.Timestamp), thumbnail == null ? null : thumbnail.Avatar); convMap.Add(convMessage.Msisdn, mObj); isNewConversation = true; } Deployment.Current.Dispatcher.BeginInvoke(() => { if (App.ViewModel.MessageListPageCollection == null) { App.ViewModel.MessageListPageCollection = new ObservableCollection <ConversationListObject>(); } App.ViewModel.MessageListPageCollection.Insert(0, mObj); }); object[] vals = new object[2]; vals[0] = convMessage; vals[1] = isNewConversation; if (HikePubSub.SEND_NEW_MSG == type) { mPubSub.publish(HikePubSub.MESSAGE_SENT, vals); } } else if (HikePubSub.MSG_READ == type) { string msisdn = (string)obj; try { ConversationListObject convObj = convMap[msisdn]; convObj.MessageStatus = ConvMessage.State.RECEIVED_READ; //TODO : update the UI here also. } catch (KeyNotFoundException) { } } else if ((HikePubSub.USER_LEFT == type) || (HikePubSub.USER_JOINED == type)) { string msisdn = (string)obj; try { ConversationListObject convObj = convMap[msisdn]; convObj.IsOnhike = HikePubSub.USER_JOINED == type; } catch (KeyNotFoundException) { } } else if (HikePubSub.UPDATE_UI == type) { string msisdn = (string)obj; try { ConversationListObject convObj = convMap[msisdn]; Deployment.Current.Dispatcher.BeginInvoke(() => { convObj.NotifyPropertyChanged("Msisdn"); }); } catch (KeyNotFoundException) { } } else if (HikePubSub.SMS_CREDIT_CHANGED == type) { Deployment.Current.Dispatcher.BeginInvoke(() => { creditsTxtBlck.Text = Convert.ToString((int)obj); }); } }