/// <summary> /// Initializes a new instance of the class to copy an existing <see cref="T:GsmComm.GsmCommunication.PhonebookEntry" />. /// </summary> /// <param name="entry">The entry to copy.</param> public PhonebookEntry(PhonebookEntry entry) { this.index = entry.Index; this.number = entry.Number; this.type = entry.type; this.text = entry.Text; }
/// <summary> /// Initializes a new instance of the class using the specified values. /// </summary> /// <param name="entry">The phonebook entry</param> /// <param name="storage">The storage the entry was read from.</param> public PhonebookEntryWithStorage(PhonebookEntry entry, string storage) : base(entry) { this.storage = storage; }
/// <summary> /// Initializes a new instance of the class using the specified values. /// </summary> /// <param name="entry">The phonebook entry</param> /// <param name="storage">The storage the entry was read from.</param> public PhonebookEntryWithStorage(PhonebookEntry entry, string storage) : base(entry) { this.storage = storage; }
/// <summary> /// Decodes a data stream with phonebook entries into <see cref="T:GsmComm.GsmCommunication.PhonebookEntry" /> objects. /// </summary> /// <param name="input">The entries to decode</param> /// <param name="prefix">The string the lines start with</param> private PhonebookEntry[] DecodePhonebookStream(string input, string prefix) { this.LogIt(LogLevel.Info, "Decoding phonebook entries..."); ArrayList arrayLists = new ArrayList(); Regex regex = new Regex(string.Concat(Regex.Escape(prefix), "(\\d+),\"(.+)\",(\\d+),\"(.+)\".*\\r\\n")); for (Match i = regex.Match(input); i.Success; i = i.NextMatch()) { int num = int.Parse(i.Groups[1].Value); string value = i.Groups[2].Value; int num1 = int.Parse(i.Groups[3].Value); string str = i.Groups[4].Value; arrayLists.Add(new PhonebookEntry(num, value, num1, str)); string[] strArrays = new string[9]; strArrays[0] = "Entry: index="; strArrays[1] = num.ToString(); strArrays[2] = ", number=\""; strArrays[3] = value; strArrays[4] = "\", type="; strArrays[5] = num1.ToString(); strArrays[6] = ", text=\""; strArrays[7] = str; strArrays[8] = "\""; this.LogIt(LogLevel.Info, string.Concat(strArrays)); } if (arrayLists.Count == 1) { this.LogIt(LogLevel.Info, "1 entry decoded."); } else { int count = arrayLists.Count; this.LogIt(LogLevel.Info, string.Concat(count.ToString(), " entries decoded.")); } PhonebookEntry[] phonebookEntryArray = new PhonebookEntry[arrayLists.Count]; arrayLists.CopyTo(phonebookEntryArray, 0); return phonebookEntryArray; }
/// <summary> /// AT+CPBW. Creates a new phonebook entry. /// </summary> /// <param name="entry">The entry to write.</param> /// <remarks>The <see cref="P:GsmComm.GsmCommunication.PhonebookEntry.Index" /> property of the entry is ignored, /// the entry is always saved in the first free location. All other properties must be set /// correctly.</remarks> public void WritePhonebookEntry(PhonebookEntry entry) { lock (this) { this.VerifyValidConnection(); this.LogIt(LogLevel.Info, "Writing phonebook entry..."); object[] number = new object[7]; number[0] = "AT+CPBW=,\""; number[1] = entry.Number; number[2] = "\","; number[3] = entry.Type; number[4] = ",\""; number[5] = entry.Text; number[6] = "\""; string str = string.Concat(number); this.ExecAndReceiveMultiple(str); } }
/// <summary> /// Initializes a new instance of the class to copy an existing <see cref="T:GsmComm.GsmCommunication.PhonebookEntry" />. /// </summary> /// <param name="entry">The entry to copy.</param> public PhonebookEntry(PhonebookEntry entry) { this.index = entry.Index; this.number = entry.Number; this.type = entry.type; this.text = entry.Text; }
/// <summary> /// Creates a new phonebook entry. /// </summary> /// <param name="entry">The entry to create.</param> /// <param name="storage">The storage to save the entry.</param> /// <remarks>The <see cref="P:GsmComm.GsmCommunication.PhonebookEntry.Index" /> property of the entry is ignored, /// the entry is always saved in the first free location. All other properties must be set /// correctly. /// <seealso cref="M:GsmComm.GsmCommunication.GsmCommMain.DeletePhonebookEntry(System.Int32,System.String)" /></remarks> public void CreatePhonebookEntry(PhonebookEntry entry, string storage) { this.theDevice.SelectPhonebookStorage(storage); this.theDevice.WritePhonebookEntry(entry); }