/// <summary> /// Check for contacts with description chars len > MaxAlphaCharsLen /// </summary> public static string CheckAlphaCharsLen(Contacts contacts) { // loop for each contact foreach (Contact contact in contacts.SimContacts) { // check for contact description length if (contact.Description.Length > SimADNMaxAlphaChars) { return contact.Description; } } return ""; }
/// <summary> /// Start sim update thread /// </summary> private void SimUpdate(Contacts cnts, bool isAppend) { ScanSimBefore(); // Reset status values GlobalObjUI.SimADNStatus = 1; GlobalObjUI.SimADNPosition = 0; GlobalObjUI.SimADNError = ""; // Start thread for reading process notify = new ThreadNotify(new ReadyEvent(WritingUpdate)); System.Threading.ThreadStart threadStart = delegate() { GlobalObjUI.WriteSimContactsList(cnts, isAppend); }; simThread = new System.Threading.Thread(threadStart); simThread.Start(); }
/// <summary> /// Write passed contacts on sim card (append or override) /// </summary> private void WriteContactsOnSim(Contacts contacts, bool isAppend) { // check for space on sim if (!isAppend && (contacts.SimContacts.Count > GlobalObjUI.SimADNRecordCount)) { // No enough space on sim MainClass.ShowMessage(MainWindow, "ERROR", GlobalObjUI.LMan.GetString("nosimspace"), MessageType.Error); return; } if (isAppend && (contacts.SimContacts.Count > (GlobalObjUI.SimADNRecordCount - GlobalObjUI.SimADNRecordNoEmpty))) { // No enough space on sim MainClass.ShowMessage(MainWindow, "ERROR", GlobalObjUI.LMan.GetString("nosimspace"), MessageType.Error); return; } SimUpdate(contacts, isAppend); }
/// <summary> /// Read sim contacts list. /// </summary> public static void ReadSimContactsList() { string emptyRecord = new string('F', SimADNRecordLen * 2) + "9000"; string expRecord = new string('?', SimADNRecordLen * 2) + "9000"; string retCmd = ""; SimADNRecordNoEmpty = 0; ADNrecords = new List<string>(); SimADNRecordEmptyID = new List<int>(); SimContacts = new Contacts(); // loop for each ADN records for (int l=1; l<=SimADNRecordCount; l++) { // Set record id SimADNPosition = l; // Prepare sim command simCommand = "A0B2" + l.ToString("X2") + "04" + SimADNRecordLen.ToString("X2"); simExpResponse = expRecord; simResponse = ""; simRespOk = false; retCmd = SendReceiveAdv(simCommand, ref simResponse, simExpResponse, ref simRespOk); log.Debug("GlobalObjUI.Sim::ReadSimContactsList: READ ADN REC " + l.ToString("d3") + " " + simResponse); if (retCmd != "") { // error detected SimADNError = retCmd; SimADNStatus = 3; // send notify to gui MonosimEvent(new object(), new EventArgs()); return; } if (!simRespOk) { // wrong response SimADNError = "WRONG RESPONSE: [" + simExpResponse + "] - [" + simResponse + "]"; SimADNStatus = 3; // send notify to gui MonosimEvent(new object(), new EventArgs()); return; } // check for not empty records if (simResponse != emptyRecord) { // increment counter of not empty records SimADNRecordNoEmpty++; // update records list ADNrecords.Add(simResponse.Substring(0, simResponse.Length-4)); } else { // Add to Empty record list SimADNRecordEmptyID.Add(l); } // send notify to gui MonosimEvent(new object(), new EventArgs()); } SimADNStatus = 2; // send notify to gui MonosimEvent(new object(), new EventArgs()); }
public static void WriteSimContactsList(Contacts contacts, bool isAppend) { string emptyRecord = new string('F', SimADNRecordLen * 2); string expRecord = "9000"; string retCmd = ""; string retRecord = ""; int adnRec = 0; // loop for each ADN records for (int cid=0; cid<contacts.SimContacts.Count; cid++) { if (!isAppend) { // first record adnRec = cid + 1; } else { // first empty record adnRec = SimADNRecordEmptyID[cid]; } // Set record id SimADNPosition = adnRec; // Prepare sim command simCommand = "A0DC" + adnRec.ToString("X2") + "04" + SimADNRecordLen.ToString("X2"); retStr = PrepareRecord(contacts.SimContacts[cid], out retRecord); if (retStr != "") { // error detected SimADNError = retStr; SimADNStatus = 3; // send notify to gui MonosimEvent(new object(), new EventArgs()); return; } simCommand += retRecord; simExpResponse = expRecord; simResponse = ""; simRespOk = false; retCmd = SendReceiveAdv(simCommand, ref simResponse, simExpResponse, ref simRespOk); log.Debug("GlobalObjUI.Sim::WriteSimContactsList: WRITE ADN REC " + adnRec.ToString("d3") + " " + simCommand + " < " + simResponse); if (retCmd != "") { // error detected SimADNError = retCmd; SimADNStatus = 3; // send notify to gui MonosimEvent(new object(), new EventArgs()); return; } if (!simRespOk) { // wrong response SimADNError = "WRONG RESPONSE: [" + simExpResponse + "] - [" + simResponse + "]"; SimADNStatus = 3; // send notify to gui MonosimEvent(new object(), new EventArgs()); return; } // send notify to gui MonosimEvent(new object(), new EventArgs()); } if(!isAppend) { // delete old other records for (int rid=adnRec+1; rid<=GlobalObjUI.SimADNRecordCount; rid++) { if (!SimADNRecordEmptyID.Contains(rid)) { // Set record id SimADNPosition = rid; simCommand = "A0DC" + rid.ToString("X2") + "04" + SimADNRecordLen.ToString("X2") + emptyRecord; simExpResponse = expRecord; simResponse = ""; simRespOk = false; retCmd = SendReceiveAdv(simCommand, ref simResponse, simExpResponse, ref simRespOk); log.Debug("GlobalObjUI.Sim::WriteSimContactsList: WRITE ADN REC " + rid.ToString("d3") + " " + simCommand + " < " + simResponse); if (retCmd != "") { // error detected SimADNError = retCmd; SimADNStatus = 3; // send notify to gui MonosimEvent(new object(), new EventArgs()); return; } if (!simRespOk) { // wrong response SimADNError = "WRONG RESPONSE: [" + simExpResponse + "] - [" + simResponse + "]"; SimADNStatus = 3; // send notify to gui MonosimEvent(new object(), new EventArgs()); return; } // send notify to gui MonosimEvent(new object(), new EventArgs()); } } } SimADNStatus = 2; // send notify to gui MonosimEvent(new object(), new EventArgs()); }
private void RemoveItems(ref Contacts cnts, ref ListStore lstore, TreePath[] tPath) { for(int p=(tPath.Length-1); p>=0; p--) { // remove contact from list cnts.SimContacts.RemoveAt(tPath[p].Indices[0]); } for(int p=(tPath.Length-1); p>=0; p--) { // remove contact from list TreeIter ti; bool isIter = lstore.GetIter(out ti, tPath[p]); if (isIter) { lstore.Remove(ref ti); } } }
/// <summary> /// Read sim contacts list. /// </summary> public static void ReadSimContactsList() { string emptyRecord = new string('F', SimADNRecordLen * 2) + "9000"; string expRecord = new string('?', SimADNRecordLen * 2) + "9000"; string retCmd = ""; SimADNRecordNoEmpty = 0; ADNrecords = new List <string>(); SimADNRecordEmptyID = new List <int>(); SimContacts = new Contacts(); // loop for each ADN records for (int l = 1; l <= SimADNRecordCount; l++) { // Set record id SimADNPosition = l; // Prepare sim command simCommand = "A0B2" + l.ToString("X2") + "04" + SimADNRecordLen.ToString("X2"); simExpResponse = expRecord; simResponse = ""; simRespOk = false; retCmd = SendReceiveAdv(simCommand, ref simResponse, simExpResponse, ref simRespOk); log.Debug("GlobalObjUI.Sim::ReadSimContactsList: READ ADN REC " + l.ToString("d3") + " " + simResponse); if (retCmd != "") { // error detected SimADNError = retCmd; SimADNStatus = 3; // send notify to gui MonosimEvent(new object(), new EventArgs()); return; } if (!simRespOk) { // wrong response SimADNError = "WRONG RESPONSE: [" + simExpResponse + "] - [" + simResponse + "]"; SimADNStatus = 3; // send notify to gui MonosimEvent(new object(), new EventArgs()); return; } // check for not empty records if (simResponse != emptyRecord) { // increment counter of not empty records SimADNRecordNoEmpty++; // update records list ADNrecords.Add(simResponse.Substring(0, simResponse.Length - 4)); } else { // Add to Empty record list SimADNRecordEmptyID.Add(l); } // send notify to gui MonosimEvent(new object(), new EventArgs()); } SimADNStatus = 2; // send notify to gui MonosimEvent(new object(), new EventArgs()); }
public static void WriteSimContactsList(Contacts contacts, bool isAppend) { string emptyRecord = new string('F', SimADNRecordLen * 2); string expRecord = "9000"; string retCmd = ""; string retRecord = ""; int adnRec = 0; // loop for each ADN records for (int cid = 0; cid < contacts.SimContacts.Count; cid++) { if (!isAppend) { // first record adnRec = cid + 1; } else { // first empty record adnRec = SimADNRecordEmptyID[cid]; } // Set record id SimADNPosition = adnRec; // Prepare sim command simCommand = "A0DC" + adnRec.ToString("X2") + "04" + SimADNRecordLen.ToString("X2"); retStr = PrepareRecord(contacts.SimContacts[cid], out retRecord); if (retStr != "") { // error detected SimADNError = retStr; SimADNStatus = 3; // send notify to gui MonosimEvent(new object(), new EventArgs()); return; } simCommand += retRecord; simExpResponse = expRecord; simResponse = ""; simRespOk = false; retCmd = SendReceiveAdv(simCommand, ref simResponse, simExpResponse, ref simRespOk); log.Debug("GlobalObjUI.Sim::WriteSimContactsList: WRITE ADN REC " + adnRec.ToString("d3") + " " + simCommand + " < " + simResponse); if (retCmd != "") { // error detected SimADNError = retCmd; SimADNStatus = 3; // send notify to gui MonosimEvent(new object(), new EventArgs()); return; } if (!simRespOk) { // wrong response SimADNError = "WRONG RESPONSE: [" + simExpResponse + "] - [" + simResponse + "]"; SimADNStatus = 3; // send notify to gui MonosimEvent(new object(), new EventArgs()); return; } // send notify to gui MonosimEvent(new object(), new EventArgs()); } if (!isAppend) { // delete old other records for (int rid = adnRec + 1; rid <= GlobalObjUI.SimADNRecordCount; rid++) { if (!SimADNRecordEmptyID.Contains(rid)) { // Set record id SimADNPosition = rid; simCommand = "A0DC" + rid.ToString("X2") + "04" + SimADNRecordLen.ToString("X2") + emptyRecord; simExpResponse = expRecord; simResponse = ""; simRespOk = false; retCmd = SendReceiveAdv(simCommand, ref simResponse, simExpResponse, ref simRespOk); log.Debug("GlobalObjUI.Sim::WriteSimContactsList: WRITE ADN REC " + rid.ToString("d3") + " " + simCommand + " < " + simResponse); if (retCmd != "") { // error detected SimADNError = retCmd; SimADNStatus = 3; // send notify to gui MonosimEvent(new object(), new EventArgs()); return; } if (!simRespOk) { // wrong response SimADNError = "WRONG RESPONSE: [" + simExpResponse + "] - [" + simResponse + "]"; SimADNStatus = 3; // send notify to gui MonosimEvent(new object(), new EventArgs()); return; } // send notify to gui MonosimEvent(new object(), new EventArgs()); } } } SimADNStatus = 2; // send notify to gui MonosimEvent(new object(), new EventArgs()); }