Ejemplo n.º 1
0
 public RC deleteContact(Contact contact)
 {
     bool rc = m_Contacts.Remove (contact);
     if (rc == false) {
         return RC.RC_CONTACT_COULD_NOT_BE_DELETED;
     }
     return RC.RC_OK;
 }
Ejemplo n.º 2
0
        public RC updateContact(Contact updatedContact, Contact originalContact)
        {
            if (m_Contacts.Contains (originalContact)) {
                bool rc = m_Contacts.Remove (originalContact);

                if (rc == false) {
                    return RC.RC_CONTACT_COULD_NOT_BE_UPDATED;
                }
                m_Contacts.Add (updatedContact);

                return RC.RC_OK;
            }
            return RC.RC_CONTACT_COULD_NOT_BE_UPDATED;
        }
Ejemplo n.º 3
0
        public RC addContact(Contact newContact)
        {
            //check if contact already exists
            foreach(Contact _contact in m_Contacts)
            {
                if (_contact.id == newContact.id) {
                    return RC.RC_CONTACT_ALREADY_EXISTS;
                }

                if (_contact.nickname == newContact.nickname) {
                    return RC.RC_CONTACT_ALREADY_EXISTS;
                }
            }
            m_Contacts.Add (newContact);
            return 0;
        }
Ejemplo n.º 4
0
        //TODO: test if it works
        public List<Contact> getContacts()
        {
            Dictionary<string, string> dContacts = m_MessagingManager.m_XmppManager.getContacts();
            Dictionary<string, Presence> dPresence = m_MessagingManager.m_XmppManager.getContactPresences ();
            List<Contact> contactList = new List<Contact> ();

            foreach (var item in dContacts) {
                Contact currentContact = new Contact ();
                currentContact.id = item.Value;
                currentContact.nickname = item.Key;
                currentContact.presence_type = dPresence [item.Key].Type.ToString ();
                currentContact.presence_text = dPresence [item.Key].Status;

                contactList.Add (currentContact);
            }

            return contactList;
        }
Ejemplo n.º 5
0
        //
        // actions
        //
        //TODO: implement function
        public string addContact(Dictionary<string, string> dParameters)
        {
            if (!(
                dParameters.ContainsKey ("sNickname") &&
                dParameters.ContainsKey("sEmail") &&
                dParameters.ContainsKey("sNote")
            )) {
                //TODO: throw exception
                return "";
            }

            //TODO: try to subscribe using xmpp

            //TODO: try to discover openpgp key (and otr-key)

            Contact newContact = new Contact ();
            newContact.sNickname = dParameters ["sNickname"];
            newContact.sId = dParameters ["sEmail"];
            newContact.communicationProtocols.Add (ECommunicationProtocol.EMAIL);
            newContact.sNote = dParameters ["sNote"];

            this.m_MessagingManager.m_AddressBook.addContact (newContact);
            return "";
        }
Ejemplo n.º 6
0
        private void onRosterItem(object sender, RosterItem item)
        {
            m_Logger.log(ELogLevel.LVL_TRACE, "Add new Roster item!", m_sModuleName);
            m_Contacts.Add(item.GetAttribute("jid").ToString(), item.GetAttribute("name").ToString());
            m_ClientConnection.MessageGrabber.Add(item.Jid, new BareJidComparer(), new MessageCB(MessageCallback), null);

            Contact _contact = m_ContactManager.getContactById (item.GetAttribute ("jid").ToString ());

            //checks if contact is in addressbook
            //TODO: check if this test works
            if (_contact.id == null) {
                Contact newContact = new Contact ();
                newContact.bIsXmppSupported = true;
                newContact.bIsEmailSupported = null;
                newContact.id = item.GetAttribute ("jid").ToString ();
                newContact.nickname = item.GetAttribute ("name").ToString ();

                return;
            }

            //Update contacts xmpp support
            _contact.bIsXmppSupported = true;

            //TODO: check if update contact is needed
            //m_ContactManager.updateContact (_contact);
        }