private void buttonOk_Click(object sender, EventArgs e) { CBuddyRecord record; if (BuddyId >= 0) { record = CBuddyList.getInstance().getRecord(BuddyId); CBuddyList.getInstance().deleteRecord(BuddyId); } else { if (textBoxNumber.Text.Length == 0) return; record = new CBuddyRecord(); } record.FirstName = textBoxName.Text; //record.LastName = _lname.Caption; record.Number = textBoxNumber.Text; record.PresenceEnabled = checkBoxPresence.Checked; CBuddyList.getInstance().addRecord(record); CBuddyList.getInstance().save(); Close(); }
public void addRecord(CBuddyRecord record) { // Call stack to add buddy and get buddy id // TODO int buddyindex = Telephony.CCallManager.CommonProxy.addBuddy(record.Number); if (buddyindex == -1) { Random rnd = new System.Random(DateTime.Now.Millisecond); buddyindex = rnd.Next(10000); for (int i = 0; i < 30000; i++) { buddyindex = rnd.Next(10000); } } record.Id = buddyindex; // add record to buddylist _buddyList.Add(record.Id, record); }
private void initialize() { XmlDocument xmlDocument = new XmlDocument(); try { xmlDocument.Load(XMLPhonebookFile); } catch (System.IO.FileNotFoundException ee) { System.Console.WriteLine(ee.Message); XmlNode root = xmlDocument.CreateNode("element", "Phonebook", ""); xmlDocument.AppendChild(root); } catch (System.Xml.XmlException e) { System.Console.WriteLine(e.Message); } // initialize internal list _buddyList = new Dictionary<int, CBuddyRecord>(); XmlNodeList list = xmlDocument.SelectNodes("/Phonebook/Record"); foreach (XmlNode item in list) { CBuddyRecord record = new CBuddyRecord(); XmlNode snode = item.SelectSingleNode(FIRSTNAME); if ((snode != null) && (snode.FirstChild.Value != null)) record.FirstName = snode.FirstChild.Value; snode = item.SelectSingleNode(LASTNAME); if ((snode != null) && (snode.FirstChild.Value != null)) record.LastName = snode.FirstChild.Value; snode = item.SelectSingleNode(PHONE_NUMBER); if ((snode != null) && (snode.FirstChild.Value != null)) record.Number = snode.FirstChild.Value; snode = item.SelectSingleNode(PHONE_URI); if ((snode != null) && (snode.FirstChild != null)) record.Uri = snode.FirstChild.Value; //_buddyList.Add(record.Id, record); this.addRecord(record); } }
public void addRecord(CBuddyRecord record) { int buddyindex = -1; buddyindex = Messenger.addBuddy(record.Number, record.PresenceEnabled); // shouldn't happen!!!! if (buddyindex == -1) return; //System.Diagnostics.Debug.WriteLine(""); record.Id = buddyindex; // add record to buddylist _buddyList.Add(record.Id, record); }
public void initialize() { XmlDocument xmlDocument = new XmlDocument(); try { xmlDocument.Load(XMLPhonebookFile); } catch (System.IO.FileNotFoundException ee) { System.Console.WriteLine(ee.Message); XmlNode root = xmlDocument.CreateNode("element", "Phonebook", ""); xmlDocument.AppendChild(root); } catch (System.Xml.XmlException e) { System.Console.WriteLine(e.Message); } XmlNodeList list = xmlDocument.SelectNodes("/Phonebook/Record"); foreach (XmlNode item in list) { CBuddyRecord record = new CBuddyRecord(); XmlNode snode = item.SelectSingleNode(FIRSTNAME); if ((snode != null) && (snode.FirstChild.Value != null)) record.FirstName = snode.FirstChild.Value; snode = item.SelectSingleNode(LASTNAME); if ((snode != null) && (snode.FirstChild != null) && (snode.FirstChild.Value != null)) record.LastName = snode.FirstChild.Value; snode = item.SelectSingleNode(PHONE_NUMBER); if ((snode != null) && (snode.FirstChild.Value != null)) record.Number = snode.FirstChild.Value; snode = item.SelectSingleNode(PHONE_URI); if ((snode != null) && (snode.FirstChild != null)) record.Uri = snode.FirstChild.Value; snode = item.SelectSingleNode(PHONE_PRESENCE); if ((snode != null) && (snode.FirstChild != null)) record.PresenceEnabled = (snode.FirstChild.Value == "" ? false : true); this.addRecord(record); } }
bool saveLink_Softkey(int keyId) { CBuddyRecord record; if (BuddyId >= 0) { record = CBuddyList.getInstance().getRecord(BuddyId); CBuddyList.getInstance().deleteRecord(BuddyId); } else { record = new CBuddyRecord(); } record.FirstName = _fname.Caption; record.LastName = _lname.Caption; record.Number = _number.Caption; CBuddyList.getInstance().addRecord(record); CBuddyList.getInstance().save(); _controller.previousPage(); return true; }