Пример #1
0
        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);
              }
        }
Пример #2
0
        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);
        }