diff --git a/source/CSV_Row_Assigner.Designer.cs b/source/CSV_Row_Assigner.Designer.cs index 34eecf1..ca5af46 100644 --- a/source/CSV_Row_Assigner.Designer.cs +++ b/source/CSV_Row_Assigner.Designer.cs @@ -38,13 +38,15 @@ private void InitializeComponent() this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label_error = new System.Windows.Forms.Label(); - this.label_dim = new System.Windows.Forms.Label(); + this.button_regsave = new System.Windows.Forms.Button(); + this.button_regload = new System.Windows.Forms.Button(); + this.label_assign = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(233, 13); + this.label1.Location = new System.Drawing.Point(136, 14); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(55, 13); this.label1.TabIndex = 0; @@ -57,7 +59,7 @@ private void InitializeComponent() this.combo_Encoding.Items.AddRange(new object[] { "Unicode", "ISO-8859-1"}); - this.combo_Encoding.Location = new System.Drawing.Point(291, 10); + this.combo_Encoding.Location = new System.Drawing.Point(194, 10); this.combo_Encoding.Name = "combo_Encoding"; this.combo_Encoding.Size = new System.Drawing.Size(121, 21); this.combo_Encoding.TabIndex = 1; @@ -65,7 +67,7 @@ private void InitializeComponent() // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(455, 13); + this.label2.Location = new System.Drawing.Point(329, 14); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(56, 13); this.label2.TabIndex = 2; @@ -79,7 +81,7 @@ private void InitializeComponent() ",", ";", "TAB"}); - this.combo_Separator.Location = new System.Drawing.Point(515, 9); + this.combo_Separator.Location = new System.Drawing.Point(389, 10); this.combo_Separator.Name = "combo_Separator"; this.combo_Separator.Size = new System.Drawing.Size(63, 21); this.combo_Separator.TabIndex = 3; @@ -87,7 +89,7 @@ private void InitializeComponent() // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(642, 13); + this.label3.Location = new System.Drawing.Point(470, 14); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(50, 13); this.label3.TabIndex = 4; @@ -100,7 +102,7 @@ private void InitializeComponent() this.combo_Headers.Items.AddRange(new object[] { "Yes", "No"}); - this.combo_Headers.Location = new System.Drawing.Point(694, 9); + this.combo_Headers.Location = new System.Drawing.Point(522, 10); this.combo_Headers.Name = "combo_Headers"; this.combo_Headers.Size = new System.Drawing.Size(96, 21); this.combo_Headers.TabIndex = 5; @@ -124,7 +126,7 @@ private void InitializeComponent() this.label5.Size = new System.Drawing.Size(878, 25); this.label5.TabIndex = 7; this.label5.Text = "Please assign the CSV coloumns to the correct data fields, then close the window!" + - ""; + ""; // // label_error // @@ -135,21 +137,43 @@ private void InitializeComponent() this.label_error.TabIndex = 8; this.label_error.Text = "Loading the CSV failed with the following error:"; // - // label_dim + // button_regsave // - this.label_dim.AutoSize = true; - this.label_dim.Location = new System.Drawing.Point(861, 12); - this.label_dim.Name = "label_dim"; - this.label_dim.Size = new System.Drawing.Size(64, 13); - this.label_dim.TabIndex = 9; - this.label_dim.Text = "Dimensions:"; + this.button_regsave.Location = new System.Drawing.Point(907, 10); + this.button_regsave.Name = "button_regsave"; + this.button_regsave.Size = new System.Drawing.Size(95, 23); + this.button_regsave.TabIndex = 9; + this.button_regsave.Text = "Save To File"; + this.button_regsave.UseVisualStyleBackColor = true; + this.button_regsave.Click += new System.EventHandler(this.button_regsave_Click); + // + // button_regload + // + this.button_regload.Location = new System.Drawing.Point(808, 10); + this.button_regload.Name = "button_regload"; + this.button_regload.Size = new System.Drawing.Size(95, 23); + this.button_regload.TabIndex = 10; + this.button_regload.Text = "Load From File"; + this.button_regload.UseVisualStyleBackColor = true; + this.button_regload.Click += new System.EventHandler(this.button_regload_Click); + // + // label_assign + // + this.label_assign.AutoSize = true; + this.label_assign.Location = new System.Drawing.Point(733, 14); + this.label_assign.Name = "label_assign"; + this.label_assign.Size = new System.Drawing.Size(69, 13); + this.label_assign.TabIndex = 11; + this.label_assign.Text = "Assignments:"; // // CSV_Row_Assigner // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1014, 629); - this.Controls.Add(this.label_dim); + this.Controls.Add(this.label_assign); + this.Controls.Add(this.button_regload); + this.Controls.Add(this.button_regsave); this.Controls.Add(this.label_error); this.Controls.Add(this.label5); this.Controls.Add(this.label4); @@ -181,7 +205,9 @@ private void InitializeComponent() private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label_error; - private System.Windows.Forms.Label label_dim; + private System.Windows.Forms.Button button_regsave; + private System.Windows.Forms.Button button_regload; + private System.Windows.Forms.Label label_assign; } diff --git a/source/CSV_Row_Assigner.cs b/source/CSV_Row_Assigner.cs index 037ade4..3585c84 100644 --- a/source/CSV_Row_Assigner.cs +++ b/source/CSV_Row_Assigner.cs @@ -40,7 +40,6 @@ public CSV_Row_Assigner(string the_filename, ref List the_LineList, re combo_Headers.SelectedIndexChanged += new System.EventHandler(this.someCombo_SelectedIndexChanged); CSV_SettingsChanged(); - } private void CSV_SettingsChanged() @@ -140,7 +139,7 @@ private void CSV_ReDrawMain(string reader_success) // then reset the arrays int coloumns = my_LineList[0].GetLength(0); - label_dim.Text = "Dimensions: " + my_LineList.Count + " x " + coloumns; + this.Text = "CSV Row Assigner" + " (" + my_LineList.Count + " x " + coloumns + ")"; combo_array = new ComboBox[coloumns]; label_array = new Label[5, coloumns]; @@ -268,5 +267,110 @@ private void someCombo_SelectedIndexChanged(object sender, EventArgs e) // re run everything CSV_SettingsChanged(); } + + private void combo_set(ComboBox cb_to_set, string value_to_set) + { + if (cb_to_set.Items.Count > 0) + { + for (int i = 0; i < cb_to_set.Items.Count; i++) + { + if (cb_to_set.Items[i].ToString() == value_to_set) + { + cb_to_set.SelectedIndex = i; + return; + } + } + } + } + + private void button_regsave_Click(object sender, EventArgs e) + { + string FullCFGfilePath = Form1.MySaveFolder + System.IO.Path.DirectorySeparatorChar + "CCW-CSV-Assigner.config"; + StringBuilder sb = new StringBuilder(); + + sb.AppendLine("cfg_csv_encoding" + "\t" + combo_Encoding.SelectedItem.ToString()); + sb.AppendLine("cfg_csv_separator" + "\t" + combo_Separator.SelectedItem.ToString()); + sb.AppendLine("cfg_csv_headers" + "\t" + combo_Headers.SelectedItem.ToString()); + + + for (int i = 0; i < combo_array.Length; i++) + { + + sb.AppendLine("cfg_csv_combo_" + i.ToString() + "\t" + combo_array[i].SelectedItem.ToString()); + + // for (int j = 0; j < combo_options.GetLength(0); j++) + // { + // if (headers[i] == combo_options[j]) + // { + // combo_array[i].SelectedIndex = j; + //} + // } + } + + + System.IO.File.WriteAllText(FullCFGfilePath, sb.ToString(), Encoding.UTF8); + + + } + + private void button_regload_Click(object sender, EventArgs e) + { + + string FullCFGfilePath = Form1.MySaveFolder + System.IO.Path.DirectorySeparatorChar + "CCW-CSV-Assigner.config"; + + if (System.IO.File.Exists(FullCFGfilePath)) + { + System.IO.StreamReader file_cleartext_read; + file_cleartext_read = new System.IO.StreamReader(FullCFGfilePath, Encoding.UTF8); + string curline; + StringBuilder builder = new StringBuilder(); + while ((curline = file_cleartext_read.ReadLine()) != null) + { + // hachre CCW Bugfix: 3.0.0.2 (ComboBox loading Problem in Mono) - previously: builder.Append(curline + "\r\n"); + builder.Append(curline + Environment.NewLine); + } + file_cleartext_read.Close(); + + // then regEx Split by NewLine into array of lines + string[] allParseLines = System.Text.RegularExpressions.Regex.Split(builder.ToString(), Environment.NewLine); + + foreach (string ParseLine in allParseLines) + { + if (ParseLine == string.Empty) { continue; } // skip empty lines + if (ParseLine.IndexOf("\t") == -1) { continue; } // skip lines without TAB + if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "cfg_csv_separator") { combo_set(combo_Separator, ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } + if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "cfg_csv_headers") { combo_set(combo_Headers, ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } + if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "cfg_csv_encoding") { combo_set(combo_Encoding, ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } + + if (ParseLine.Substring(0, ParseLine.IndexOf("\t")).StartsWith("cfg_csv_combo_") == true) + { + // value to set to: + string set_value = ParseLine.Substring(ParseLine.IndexOf("\t") + 1); + + // combobox we are setting this to + string count_value = ParseLine.Substring(ParseLine.IndexOf("cfg_csv_combo_") + "cfg_csv_combo_".Length); + int count_box = Convert.ToInt32(count_value.Substring(0, count_value.IndexOf("\t"))); + + if ((combo_array.Length-1) >= count_box) + { + for (int j = 0; j < combo_options.GetLength(0); j++) + { + if (combo_options[j] == set_value) + { + combo_array[count_box].SelectedIndex = j; + } + } + } + // ; + continue; + } + + + } + + } + } + + } } diff --git a/source/EditConfiguration.Designer.cs b/source/EditConfiguration.Designer.cs index ec774a7..f403fc7 100644 --- a/source/EditConfiguration.Designer.cs +++ b/source/EditConfiguration.Designer.cs @@ -44,9 +44,13 @@ private void InitializeComponent() this.lbl_gMail_pass = new System.Windows.Forms.Label(); this.textBox_gLogin = new System.Windows.Forms.TextBox(); this.textBox_gPass = new System.Windows.Forms.TextBox(); - this.OPT_fritzXML_order = new System.Windows.Forms.CheckBox(); this.OPT_DUPren = new System.Windows.Forms.CheckBox(); this.checkBox_checkVersion = new System.Windows.Forms.CheckBox(); + this.checkBox_cleanSpace = new System.Windows.Forms.CheckBox(); + this.checkBox_cleanSquareBrackets = new System.Windows.Forms.CheckBox(); + this.checkBox_cleanLetters = new System.Windows.Forms.CheckBox(); + this.label_google_hint = new System.Windows.Forms.Label(); + this.checkBox_cleanaddzeroprefix = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // lbl_configtitle @@ -82,7 +86,7 @@ private void InitializeComponent() // checkBox_cleanXchar // this.checkBox_cleanXchar.AutoSize = true; - this.checkBox_cleanXchar.Location = new System.Drawing.Point(16, 307); + this.checkBox_cleanXchar.Location = new System.Drawing.Point(16, 310); this.checkBox_cleanXchar.Name = "checkBox_cleanXchar"; this.checkBox_cleanXchar.Size = new System.Drawing.Size(69, 17); this.checkBox_cleanXchar.TabIndex = 8; @@ -92,7 +96,7 @@ private void InitializeComponent() // checkBox_cleanHyphen // this.checkBox_cleanHyphen.AutoSize = true; - this.checkBox_cleanHyphen.Location = new System.Drawing.Point(16, 284); + this.checkBox_cleanHyphen.Location = new System.Drawing.Point(16, 287); this.checkBox_cleanHyphen.Name = "checkBox_cleanHyphen"; this.checkBox_cleanHyphen.Size = new System.Drawing.Size(67, 17); this.checkBox_cleanHyphen.TabIndex = 7; @@ -102,7 +106,7 @@ private void InitializeComponent() // checkBox_cleanHashKey // this.checkBox_cleanHashKey.AutoSize = true; - this.checkBox_cleanHashKey.Location = new System.Drawing.Point(16, 261); + this.checkBox_cleanHashKey.Location = new System.Drawing.Point(16, 264); this.checkBox_cleanHashKey.Name = "checkBox_cleanHashKey"; this.checkBox_cleanHashKey.Size = new System.Drawing.Size(71, 17); this.checkBox_cleanHashKey.TabIndex = 10; @@ -112,7 +116,7 @@ private void InitializeComponent() // checkBox_cleanBrackets // this.checkBox_cleanBrackets.AutoSize = true; - this.checkBox_cleanBrackets.Location = new System.Drawing.Point(16, 238); + this.checkBox_cleanBrackets.Location = new System.Drawing.Point(16, 241); this.checkBox_cleanBrackets.Name = "checkBox_cleanBrackets"; this.checkBox_cleanBrackets.Size = new System.Drawing.Size(104, 17); this.checkBox_cleanBrackets.TabIndex = 9; @@ -123,7 +127,7 @@ private void InitializeComponent() // this.label_cleanheader.AutoSize = true; this.label_cleanheader.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label_cleanheader.Location = new System.Drawing.Point(13, 213); + this.label_cleanheader.Location = new System.Drawing.Point(13, 216); this.label_cleanheader.Name = "label_cleanheader"; this.label_cleanheader.Size = new System.Drawing.Size(289, 20); this.label_cleanheader.TabIndex = 11; @@ -142,7 +146,7 @@ private void InitializeComponent() // checkBox_cleanSlash // this.checkBox_cleanSlash.AutoSize = true; - this.checkBox_cleanSlash.Location = new System.Drawing.Point(16, 330); + this.checkBox_cleanSlash.Location = new System.Drawing.Point(16, 333); this.checkBox_cleanSlash.Name = "checkBox_cleanSlash"; this.checkBox_cleanSlash.Size = new System.Drawing.Size(69, 17); this.checkBox_cleanSlash.TabIndex = 13; @@ -152,70 +156,61 @@ private void InitializeComponent() // OPT_importOther // this.OPT_importOther.AutoSize = true; - this.OPT_importOther.Location = new System.Drawing.Point(16, 137); + this.OPT_importOther.Location = new System.Drawing.Point(16, 109); this.OPT_importOther.Name = "OPT_importOther"; - this.OPT_importOther.Size = new System.Drawing.Size(319, 17); + this.OPT_importOther.Size = new System.Drawing.Size(301, 30); this.OPT_importOther.TabIndex = 14; - this.OPT_importOther.Text = "Use \"Other\" phone number from Outlook if Home/Work empty"; + this.OPT_importOther.Text = "Import additional phone numbers if a home or work number\r\nfield remains empty. So" + + "urce: Outlook:Other / Google:Main.\r\n"; this.OPT_importOther.UseVisualStyleBackColor = true; // // label1 // this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.Location = new System.Drawing.Point(12, 360); + this.label1.Location = new System.Drawing.Point(12, 447); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(268, 20); + this.label1.Size = new System.Drawing.Size(323, 20); this.label1.TabIndex = 17; - this.label1.Text = "Google account for direct import"; + this.label1.Text = "Google account for direct import/export"; // // lbl_gMail_login // this.lbl_gMail_login.AutoSize = true; - this.lbl_gMail_login.Location = new System.Drawing.Point(17, 391); + this.lbl_gMail_login.Location = new System.Drawing.Point(17, 479); this.lbl_gMail_login.Name = "lbl_gMail_login"; - this.lbl_gMail_login.Size = new System.Drawing.Size(64, 13); + this.lbl_gMail_login.Size = new System.Drawing.Size(73, 13); this.lbl_gMail_login.TabIndex = 18; - this.lbl_gMail_login.Text = "gMail Login:"; + this.lbl_gMail_login.Text = "Google Login:"; // // lbl_gMail_pass // this.lbl_gMail_pass.AutoSize = true; - this.lbl_gMail_pass.Location = new System.Drawing.Point(17, 417); + this.lbl_gMail_pass.Location = new System.Drawing.Point(17, 505); this.lbl_gMail_pass.Name = "lbl_gMail_pass"; - this.lbl_gMail_pass.Size = new System.Drawing.Size(84, 13); + this.lbl_gMail_pass.Size = new System.Drawing.Size(93, 13); this.lbl_gMail_pass.TabIndex = 19; - this.lbl_gMail_pass.Text = "gMail Password:"; + this.lbl_gMail_pass.Text = "Google Password:"; // // textBox_gLogin // - this.textBox_gLogin.Location = new System.Drawing.Point(100, 388); + this.textBox_gLogin.Location = new System.Drawing.Point(125, 476); this.textBox_gLogin.Name = "textBox_gLogin"; this.textBox_gLogin.Size = new System.Drawing.Size(180, 20); this.textBox_gLogin.TabIndex = 20; // // textBox_gPass // - this.textBox_gPass.Location = new System.Drawing.Point(100, 415); + this.textBox_gPass.Location = new System.Drawing.Point(125, 503); this.textBox_gPass.Name = "textBox_gPass"; this.textBox_gPass.Size = new System.Drawing.Size(180, 20); this.textBox_gPass.TabIndex = 21; this.textBox_gPass.UseSystemPasswordChar = true; // - // OPT_fritzXML_order - // - this.OPT_fritzXML_order.AutoSize = true; - this.OPT_fritzXML_order.Location = new System.Drawing.Point(16, 114); - this.OPT_fritzXML_order.Name = "OPT_fritzXML_order"; - this.OPT_fritzXML_order.Size = new System.Drawing.Size(242, 17); - this.OPT_fritzXML_order.TabIndex = 22; - this.OPT_fritzXML_order.Text = "Fritz!XML Export: Work Nr. before Home Nr. ?"; - this.OPT_fritzXML_order.UseVisualStyleBackColor = true; - // // OPT_DUPren // this.OPT_DUPren.AutoSize = true; - this.OPT_DUPren.Location = new System.Drawing.Point(16, 161); + this.OPT_DUPren.Location = new System.Drawing.Point(16, 144); this.OPT_DUPren.Name = "OPT_DUPren"; this.OPT_DUPren.Size = new System.Drawing.Size(296, 17); this.OPT_DUPren.TabIndex = 24; @@ -225,21 +220,74 @@ private void InitializeComponent() // checkBox_checkVersion // this.checkBox_checkVersion.AutoSize = true; - this.checkBox_checkVersion.Location = new System.Drawing.Point(16, 184); + this.checkBox_checkVersion.Location = new System.Drawing.Point(16, 167); this.checkBox_checkVersion.Name = "checkBox_checkVersion"; this.checkBox_checkVersion.Size = new System.Drawing.Size(182, 17); this.checkBox_checkVersion.TabIndex = 25; this.checkBox_checkVersion.Text = "Check for new version on startup"; this.checkBox_checkVersion.UseVisualStyleBackColor = true; // + // checkBox_cleanSpace + // + this.checkBox_cleanSpace.AutoSize = true; + this.checkBox_cleanSpace.Location = new System.Drawing.Point(16, 356); + this.checkBox_cleanSpace.Name = "checkBox_cleanSpace"; + this.checkBox_cleanSpace.Size = new System.Drawing.Size(158, 17); + this.checkBox_cleanSpace.TabIndex = 26; + this.checkBox_cleanSpace.Text = "Keep \" \" (space characters)"; + this.checkBox_cleanSpace.UseVisualStyleBackColor = true; + // + // checkBox_cleanSquareBrackets + // + this.checkBox_cleanSquareBrackets.AutoSize = true; + this.checkBox_cleanSquareBrackets.Location = new System.Drawing.Point(16, 379); + this.checkBox_cleanSquareBrackets.Name = "checkBox_cleanSquareBrackets"; + this.checkBox_cleanSquareBrackets.Size = new System.Drawing.Size(104, 17); + this.checkBox_cleanSquareBrackets.TabIndex = 27; + this.checkBox_cleanSquareBrackets.Text = "Keep \"[\" and \"]\""; + this.checkBox_cleanSquareBrackets.UseVisualStyleBackColor = true; + // + // checkBox_cleanLetters + // + this.checkBox_cleanLetters.AutoSize = true; + this.checkBox_cleanLetters.Location = new System.Drawing.Point(16, 402); + this.checkBox_cleanLetters.Name = "checkBox_cleanLetters"; + this.checkBox_cleanLetters.Size = new System.Drawing.Size(129, 17); + this.checkBox_cleanLetters.TabIndex = 28; + this.checkBox_cleanLetters.Text = "Keep \"a-z\" and \"A-Z\""; + this.checkBox_cleanLetters.UseVisualStyleBackColor = true; + // + // label_google_hint + // + this.label_google_hint.AutoSize = true; + this.label_google_hint.Location = new System.Drawing.Point(17, 526); + this.label_google_hint.Name = "label_google_hint"; + this.label_google_hint.Size = new System.Drawing.Size(320, 13); + this.label_google_hint.TabIndex = 29; + this.label_google_hint.Text = "If you leave the password field empty, you will be asked each time."; + // + // checkBox_cleanaddzeroprefix + // + this.checkBox_cleanaddzeroprefix.AutoSize = true; + this.checkBox_cleanaddzeroprefix.Location = new System.Drawing.Point(16, 425); + this.checkBox_cleanaddzeroprefix.Name = "checkBox_cleanaddzeroprefix"; + this.checkBox_cleanaddzeroprefix.Size = new System.Drawing.Size(232, 17); + this.checkBox_cleanaddzeroprefix.TabIndex = 30; + this.checkBox_cleanaddzeroprefix.Text = "Alway add \"0\" prefix to access outside lines"; + this.checkBox_cleanaddzeroprefix.UseVisualStyleBackColor = true; + // // EditConfiguration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(362, 474); + this.ClientSize = new System.Drawing.Size(362, 549); + this.Controls.Add(this.checkBox_cleanaddzeroprefix); + this.Controls.Add(this.label_google_hint); + this.Controls.Add(this.checkBox_cleanLetters); + this.Controls.Add(this.checkBox_cleanSquareBrackets); + this.Controls.Add(this.checkBox_cleanSpace); this.Controls.Add(this.checkBox_checkVersion); this.Controls.Add(this.OPT_DUPren); - this.Controls.Add(this.OPT_fritzXML_order); this.Controls.Add(this.textBox_gPass); this.Controls.Add(this.textBox_gLogin); this.Controls.Add(this.lbl_gMail_pass); @@ -256,6 +304,8 @@ private void InitializeComponent() this.Controls.Add(this.lbl_configtitle); this.Controls.Add(this.OPT_adjustcol); this.Controls.Add(this.OPT_hidecol); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; this.Name = "EditConfiguration"; this.Text = "EditConfiguration"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.EditConfiguration_FormClosing); @@ -282,8 +332,12 @@ private void InitializeComponent() private System.Windows.Forms.Label lbl_gMail_pass; private System.Windows.Forms.TextBox textBox_gLogin; private System.Windows.Forms.TextBox textBox_gPass; - private System.Windows.Forms.CheckBox OPT_fritzXML_order; private System.Windows.Forms.CheckBox OPT_DUPren; private System.Windows.Forms.CheckBox checkBox_checkVersion; + private System.Windows.Forms.CheckBox checkBox_cleanSpace; + private System.Windows.Forms.CheckBox checkBox_cleanSquareBrackets; + private System.Windows.Forms.CheckBox checkBox_cleanLetters; + private System.Windows.Forms.Label label_google_hint; + private System.Windows.Forms.CheckBox checkBox_cleanaddzeroprefix; } } \ No newline at end of file diff --git a/source/EditConfiguration.cs b/source/EditConfiguration.cs index 1f54aff..4160518 100644 --- a/source/EditConfiguration.cs +++ b/source/EditConfiguration.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; @@ -16,7 +15,6 @@ public EditConfiguration() OPT_hidecol.Checked = Form1.cfg_hideemptycols; OPT_adjustcol.Checked = Form1.cfg_adjustablecols; OPT_prefixNONFB.Checked = Form1.cfg_prefixNONFB; - OPT_fritzXML_order.Checked = Form1.cfg_fritzWorkFirst; OPT_importOther.Checked = Form1.cfg_importOther; OPT_DUPren.Checked = Form1.cfg_DUPren; @@ -26,6 +24,12 @@ public EditConfiguration() checkBox_cleanSlash.Checked = !Form1.clean_slash; checkBox_cleanHyphen.Checked = !Form1.clean_hyphen; checkBox_cleanXchar.Checked = !Form1.clean_xchar; + checkBox_cleanSpace.Checked = !Form1.clean_space; + checkBox_cleanSquareBrackets.Checked = !Form1.clean_squarebrackets; + checkBox_cleanLetters.Checked = !Form1.clean_letters; + checkBox_cleanaddzeroprefix.Checked = Form1.clean_addzeroprefix; + + textBox_gLogin.Text = Form1.g_login; textBox_gPass.Text = Form1.g_pass; @@ -39,7 +43,6 @@ private void EditConfiguration_FormClosing(object sender, FormClosingEventArgs e Form1.cfg_hideemptycols = OPT_hidecol.Checked; Form1.cfg_adjustablecols = OPT_adjustcol.Checked; Form1.cfg_prefixNONFB = OPT_prefixNONFB.Checked; - Form1.cfg_fritzWorkFirst = OPT_fritzXML_order.Checked; Form1.cfg_importOther = OPT_importOther.Checked; Form1.cfg_DUPren = OPT_DUPren.Checked; @@ -48,6 +51,12 @@ private void EditConfiguration_FormClosing(object sender, FormClosingEventArgs e Form1.clean_slash = !checkBox_cleanSlash.Checked; Form1.clean_hyphen = !checkBox_cleanHyphen.Checked; Form1.clean_xchar = !checkBox_cleanXchar.Checked; + Form1.clean_space = !checkBox_cleanSpace.Checked; + Form1.clean_squarebrackets = !checkBox_cleanSquareBrackets.Checked; + Form1.clean_letters = !checkBox_cleanLetters.Checked; + Form1.clean_addzeroprefix = checkBox_cleanaddzeroprefix.Checked; + + Form1.g_login = textBox_gLogin.Text; Form1.g_pass = textBox_gPass.Text; diff --git a/source/Form1.Designer.cs b/source/Form1.Designer.cs index f7a23bb..9158f5a 100644 --- a/source/Form1.Designer.cs +++ b/source/Form1.Designer.cs @@ -85,6 +85,8 @@ private void InitializeComponent() this.btn_save_GrandstreamGXP = new System.Windows.Forms.Button(); this.btn_save_Auerswald = new System.Windows.Forms.Button(); this.btn_save_googleContacts = new System.Windows.Forms.Button(); + this.btn_save_panasonicCSV = new System.Windows.Forms.Button(); + this.btn_save_vCard_Gigaset = new System.Windows.Forms.Button(); this.panel_left = new System.Windows.Forms.Panel(); this.label4 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); @@ -135,7 +137,8 @@ private void InitializeComponent() this.btn_save_FritzXML.TabIndex = 2; this.btn_save_FritzXML.Text = "Fritz!Box XML"; this.toolTip1.SetToolTip(this.btn_save_FritzXML, "Exports contacts to the XML file the Fritz!Box needs when restoring the phonebook" + - "."); + ".\r\n\r\nIf shift is pressed when clicking this button, the fax numbers will also be" + + " exported to the XML file."); this.btn_save_FritzXML.UseVisualStyleBackColor = true; this.btn_save_FritzXML.Click += new System.EventHandler(this.btn_save_FritzXML_Click); // @@ -188,21 +191,21 @@ private void InitializeComponent() // // button_7270 // - this.button_7270.Location = new System.Drawing.Point(267, 54); + this.button_7270.Location = new System.Drawing.Point(198, 54); this.button_7270.Name = "button_7270"; - this.button_7270.Size = new System.Drawing.Size(46, 19); + this.button_7270.Size = new System.Drawing.Size(66, 19); this.button_7270.TabIndex = 8; - this.button_7270.Text = "7270"; + this.button_7270.Text = "USB Stick"; this.button_7270.UseVisualStyleBackColor = true; this.button_7270.Click += new System.EventHandler(this.button_7270_Click); // // button_7390 // - this.button_7390.Location = new System.Drawing.Point(314, 54); + this.button_7390.Location = new System.Drawing.Point(267, 54); this.button_7390.Name = "button_7390"; - this.button_7390.Size = new System.Drawing.Size(46, 19); + this.button_7390.Size = new System.Drawing.Size(93, 19); this.button_7390.TabIndex = 7; - this.button_7390.Text = "7390"; + this.button_7390.Text = "Internal Memory"; this.button_7390.UseVisualStyleBackColor = true; this.button_7390.Click += new System.EventHandler(this.button_7390_Click); // @@ -289,9 +292,9 @@ private void InitializeComponent() this.combo_VIP.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.combo_VIP.FormattingEnabled = true; this.combo_VIP.Items.AddRange(new object[] { - "when hell freezes over (never)", - "when they have a nickname", - "when text VIP is in the Comment/Notes"}); + "never", + "if contact has a nickname", + "if text VIP is in the Comment/Notes"}); this.combo_VIP.Location = new System.Drawing.Point(132, 78); this.combo_VIP.Name = "combo_VIP"; this.combo_VIP.Size = new System.Drawing.Size(221, 21); @@ -344,7 +347,7 @@ private void InitializeComponent() this.btn_save_vCard.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btn_save_vCard.Location = new System.Drawing.Point(836, 108); this.btn_save_vCard.Name = "btn_save_vCard"; - this.btn_save_vCard.Size = new System.Drawing.Size(167, 35); + this.btn_save_vCard.Size = new System.Drawing.Size(83, 35); this.btn_save_vCard.TabIndex = 14; this.btn_save_vCard.Text = "vCard"; this.toolTip1.SetToolTip(this.btn_save_vCard, resources.GetString("btn_save_vCard.ToolTip")); @@ -684,8 +687,8 @@ private void InitializeComponent() this.btn_read_googleContacts.Size = new System.Drawing.Size(167, 35); this.btn_read_googleContacts.TabIndex = 29; this.btn_read_googleContacts.Text = "Google Contacts"; - this.toolTip1.SetToolTip(this.btn_read_googleContacts, "Directly imports contacts from a Google Mail Account\r\n(without the need to create" + - " a vCard as intermediate step)\r\n"); + this.toolTip1.SetToolTip(this.btn_read_googleContacts, "Directly imports contacts from a Google Mail Account\r\n\r\nHold SHIFT to select the " + + "groups you want to import from!\r\n"); this.btn_read_googleContacts.UseVisualStyleBackColor = true; this.btn_read_googleContacts.Click += new System.EventHandler(this.btn_read_googleContacts_Click); // @@ -729,6 +732,32 @@ private void InitializeComponent() this.btn_save_googleContacts.UseVisualStyleBackColor = true; this.btn_save_googleContacts.Click += new System.EventHandler(this.btn_save_googleContacts_Click); // + // btn_save_panasonicCSV + // + this.btn_save_panasonicCSV.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btn_save_panasonicCSV.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btn_save_panasonicCSV.Location = new System.Drawing.Point(836, 412); + this.btn_save_panasonicCSV.Name = "btn_save_panasonicCSV"; + this.btn_save_panasonicCSV.Size = new System.Drawing.Size(167, 35); + this.btn_save_panasonicCSV.TabIndex = 35; + this.btn_save_panasonicCSV.Text = "Panasonic"; + this.toolTip1.SetToolTip(this.btn_save_panasonicCSV, resources.GetString("btn_save_panasonicCSV.ToolTip")); + this.btn_save_panasonicCSV.UseVisualStyleBackColor = true; + this.btn_save_panasonicCSV.Click += new System.EventHandler(this.btn_save_panasonicCSV_Click); + // + // btn_save_vCard_Gigaset + // + this.btn_save_vCard_Gigaset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btn_save_vCard_Gigaset.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btn_save_vCard_Gigaset.Location = new System.Drawing.Point(920, 108); + this.btn_save_vCard_Gigaset.Name = "btn_save_vCard_Gigaset"; + this.btn_save_vCard_Gigaset.Size = new System.Drawing.Size(83, 35); + this.btn_save_vCard_Gigaset.TabIndex = 36; + this.btn_save_vCard_Gigaset.Text = "Simple vCard\r\nfor Gigaset"; + this.toolTip1.SetToolTip(this.btn_save_vCard_Gigaset, resources.GetString("btn_save_vCard_Gigaset.ToolTip")); + this.btn_save_vCard_Gigaset.UseVisualStyleBackColor = true; + this.btn_save_vCard_Gigaset.Click += new System.EventHandler(this.btn_save_vCard_Gigaset_Click); + // // panel_left // this.panel_left.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -839,6 +868,8 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1004, 582); + this.Controls.Add(this.btn_save_vCard_Gigaset); + this.Controls.Add(this.btn_save_panasonicCSV); this.Controls.Add(this.btn_save_googleContacts); this.Controls.Add(this.btn_save_Auerswald); this.Controls.Add(this.btn_save_GrandstreamGXP); @@ -869,7 +900,7 @@ private void InitializeComponent() this.Controls.Add(this.btn_read_vCard); this.Controls.Add(this.btn_read_Outlook); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MinimumSize = new System.Drawing.Size(1000, 600); + this.MinimumSize = new System.Drawing.Size(1020, 620); this.Name = "Form1"; this.Text = "Contact Conversion Wizard"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); @@ -950,6 +981,8 @@ private void InitializeComponent() private System.Windows.Forms.Button btn_save_GrandstreamGXP; private System.Windows.Forms.Button btn_save_Auerswald; private System.Windows.Forms.Button btn_save_googleContacts; + private System.Windows.Forms.Button btn_save_panasonicCSV; + private System.Windows.Forms.Button btn_save_vCard_Gigaset; } } diff --git a/source/Form1.cs b/source/Form1.cs index 9289ae3..8f4c237 100644 --- a/source/Form1.cs +++ b/source/Form1.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; @@ -16,6 +15,7 @@ using System.Collections; using System.Net; +using System.Linq; namespace Contact_Conversion_Wizard { @@ -24,22 +24,30 @@ public partial class Form1 : Form public static bool cfg_hideemptycols = false; public static bool cfg_adjustablecols = false; public static bool cfg_prefixNONFB = false; - public static bool cfg_fritzWorkFirst = false; public static bool cfg_importOther = true; public static bool clean_brackets = true; public static bool clean_slash = true; public static bool clean_hashkey = true; public static bool clean_hyphen = true; public static bool clean_xchar = true; + public static bool clean_space = true; + public static bool clean_squarebrackets = true; + public static bool clean_letters = true; + public static bool clean_addzeroprefix = false; + + public static bool cfg_DUPren = false; - public static bool cfg_checkVersion = false; + public static bool cfg_checkVersion = true; public static string g_login = ""; public static string g_pass = ""; + public static System.Text.Encoding utf8WithoutBom = new System.Text.UTF8Encoding(false); + + System.Collections.Hashtable myGroupDataHash; - string MySaveFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + System.IO.Path.DirectorySeparatorChar + "ContactConversionWizard"; + public static string MySaveFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + System.IO.Path.DirectorySeparatorChar + "ContactConversionWizard"; public Form1() { @@ -93,6 +101,8 @@ public Form1() // override default load configuration (from above) with settings from file (if any) myConfig_Load(); + + if (cfg_checkVersion == true) { backgroundWorker_updateCheck.RunWorkerAsync(); @@ -122,10 +132,6 @@ private string CleanUpNumber(string number, string country_prefix, string dial_p { // keep brackets if option to clean them set to false buffer[idx] = c; idx++; } - else if (clean_slash == false && (c == '/')) - { // keep slash if option to clean it set to false - buffer[idx] = c; idx++; - } else if (clean_hashkey == false && (c == '#')) { // keep slash if option to clean it set to false buffer[idx] = c; idx++; @@ -138,6 +144,23 @@ private string CleanUpNumber(string number, string country_prefix, string dial_p { // keep slash if option to clean it set to false buffer[idx] = c; idx++; } + else if (clean_slash == false && (c == '/')) + { // keep slash if option to clean it set to false + buffer[idx] = c; idx++; + } + else if (clean_space == false && (c == ' ')) + { // keep space if option to clean it set to false + buffer[idx] = c; idx++; + } + else if (clean_squarebrackets == false && ((c == '[') || (c == ']'))) + { // keep square brackets if option to clean them set to false + buffer[idx] = c; idx++; + } + else if (clean_letters == false && ((c >= 'a' && c <= 'z') || (c >= 'A') && (c <= 'Z'))) + { + buffer[idx] = c; idx++; + } + } return_str = new string(buffer, 0, idx); @@ -149,8 +172,14 @@ private string CleanUpNumber(string number, string country_prefix, string dial_p if (return_str.StartsWith(country_prefix)) { return_str = "0" + return_str.Substring(country_prefix.Length); } } + // add fritz!prefix is detected in the source if (return_str != "") { return_str = dial_prefix + return_str; } + // alway add "0" prefix for outside lines if the corresponding configuration option is active + if (return_str != "" && clean_addzeroprefix == true ) { return_str = "0" + return_str; } + + + } else { // treat as email @@ -183,7 +212,7 @@ private string RetrieveCountryID(string combo_string) else { // Ask the user for the correct country code - SimpleInputDialog MySimpleInputDialog = new SimpleInputDialog("Please enter your local Country Prefix here (in the format 00x or 00xx)", "CustomCountryID", true); + SimpleInputDialog MySimpleInputDialog = new SimpleInputDialog("Please enter your local Country Prefix here (in the format 00x or 00xx)", "CustomCountryID", true, false); MySimpleInputDialog.ShowDialog(); my_country_id = MySimpleInputDialog.resultstring; MySimpleInputDialog.Dispose(); @@ -443,6 +472,38 @@ private string Do_XML_replace(string to_replace) return ret_val; } + + private string Do_VCARD_replace(string to_replace) + { + string ret_val = to_replace; + + ret_val = ret_val.Replace("\\", "\\\\"); + ret_val = ret_val.Replace(";", "\\;"); + ret_val = ret_val.Replace(",", "\\,"); + ret_val = ret_val.Replace(":", "\\:"); + ret_val = ret_val.Replace("\r\n", "\\n"); // this has to be done first since it's more specific + ret_val = ret_val.Replace("\n", "\\n"); // this has to be done later + return ret_val; + } + + + private string Do_VCARD_replace_Gigaset(string to_replace) + { + string ret_val = to_replace; + ret_val = ret_val.Replace("\\", "\\\\"); + ret_val = ret_val.Replace(";", "\\;"); + + // these two must explicitly not be replaced on the dx600a + // ret_val = ret_val.Replace(",", "\\,"); + // ret_val = ret_val.Replace(":", "\\:"); + + // no newlines in gigaset + ret_val = ret_val.Replace("\r\n", ""); // this has to be done first since it's more specific + ret_val = ret_val.Replace("\n", ""); // this has to be done later + return ret_val; + } + + private bool CheckIfSeparateEntries(string nr1, string nr2, string nr3) { int nr_in_use = 0; @@ -508,6 +569,7 @@ private void disable_buttons(bool on_off) btn_save_Outlook.Enabled = false; btn_save_FritzXML.Enabled = false; btn_save_vCard.Enabled = false; + btn_save_vCard_Gigaset.Enabled = false; btn_save_FritzAdress.Enabled = false; btn_save_SnomCSV7.Enabled = false; btn_save_SnomCSV8.Enabled = false; @@ -517,6 +579,7 @@ private void disable_buttons(bool on_off) btn_save_GrandstreamGXP.Enabled = false; btn_save_Auerswald.Enabled = false; btn_save_googleContacts.Enabled = false; + btn_save_panasonicCSV.Enabled = false; button_clear.Enabled = false; button_config.Enabled = false; @@ -534,6 +597,7 @@ private void disable_buttons(bool on_off) btn_save_Outlook.Enabled = true; btn_save_FritzXML.Enabled = true; btn_save_vCard.Enabled = true; + btn_save_vCard_Gigaset.Enabled = true; btn_save_FritzAdress.Enabled = true; btn_save_SnomCSV7.Enabled = true; btn_save_SnomCSV8.Enabled = true; @@ -543,6 +607,8 @@ private void disable_buttons(bool on_off) btn_save_GrandstreamGXP.Enabled = true; btn_save_Auerswald.Enabled = true; btn_save_googleContacts.Enabled = true; + btn_save_panasonicCSV.Enabled = true; + button_clear.Enabled = true; button_config.Enabled = true; @@ -862,14 +928,33 @@ private void btn_read_googleContacts_Click(object sender, EventArgs e) // processing starts, so now we will disable the buttons first to make sure the user knows this by not having buttons to click on disable_buttons(true); - if (g_login == string.Empty || g_pass == string.Empty) + // check whether the user had the shift key pressed while calling this function and store this in a variable for further use + bool shiftpressed_for_custom_folder = false; + + if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) { shiftpressed_for_custom_folder = true; } + + if (g_login == string.Empty) { - MessageBox.Show("Please configure gMail Login and Password in the configuration menu first!"); + MessageBox.Show("Please configure Google login in the configuration menu first!"); disable_buttons(false); return; } - ReadDataReturn myReadDataReturn = read_data_googleContacts(); + string custom_google_pass = ""; + if (g_pass != string.Empty) + { + custom_google_pass = g_pass; + } + else + { + SimpleInputDialog MySimpleInputDialog = new SimpleInputDialog("Please enter the Google password for login " + g_login + ":", "Enter Google Password", false, true); + MySimpleInputDialog.ShowDialog(); + custom_google_pass = MySimpleInputDialog.resultstring; + MySimpleInputDialog.Dispose(); + } + + + ReadDataReturn myReadDataReturn = read_data_googleContacts(shiftpressed_for_custom_folder, custom_google_pass); if (myReadDataReturn.duplicates != "") MessageBox.Show(myReadDataReturn.duplicates, "The following duplicate entries could not be imported"); update_datagrid(); @@ -958,7 +1043,7 @@ private ReadDataReturn read_data_Outlook(bool customfolder, bool categoryfilter) string my_category_filter = ""; if (categoryfilter == true) { - SimpleInputDialog MySimpleInputDialog = new SimpleInputDialog("Please enter the string that must be present in the category field:", "Category Filter", false); + SimpleInputDialog MySimpleInputDialog = new SimpleInputDialog("Please enter the string that must be present in the category field:", "Category Filter", false, false); MySimpleInputDialog.ShowDialog(); my_category_filter = MySimpleInputDialog.resultstring; MySimpleInputDialog.Dispose(); @@ -1081,7 +1166,19 @@ private ReadDataReturn read_data_FritzXML(string filename) string duplicates = ""; GroupDataContact myContact = new GroupDataContact(); - System.IO.StreamReader file1 = new System.IO.StreamReader(filename, Encoding.GetEncoding("ISO-8859-1")); + + // auto detect encoding used in xml file! + string line1 = ""; + using (StreamReader reader = new StreamReader(filename)) { line1 = reader.ReadLine(); } + + // set default in case we don't find something in the first line + System.Text.Encoding fritzXMLreadencoding = utf8WithoutBom; + + if (line1.Contains("encoding=\"utf-8\"") == true) { fritzXMLreadencoding = utf8WithoutBom; } + else if (line1.Contains("encoding=\"iso-8859-1\"") == true) { fritzXMLreadencoding = Encoding.GetEncoding("ISO-8859-1"); } + else { MessageBox.Show("Unable to determine file encoding from header, defaulting to: " + fritzXMLreadencoding.EncodingName.ToString()); } + + System.IO.StreamReader file1 = new System.IO.StreamReader(filename, fritzXMLreadencoding); try { @@ -1094,6 +1191,7 @@ private ReadDataReturn read_data_FritzXML(string filename) r.MoveToContent(); + string parsing_errors = ""; while (r.ReadToFollowing("contact")) // loop starts here, if we are able to arrive at a new contact { myContact = new GroupDataContact(); // then we first clean out myContact Storage @@ -1145,8 +1243,30 @@ private ReadDataReturn read_data_FritzXML(string filename) myContact.mobile = r.ReadElementContentAsString(); continue; } + if (r.GetAttribute("type") == "fax_work") + { + if (combo_typeprefer.SelectedIndex == 0) + { // prefer storing as home + myContact.homefax = r.ReadElementContentAsString(); + } + if (combo_typeprefer.SelectedIndex == 1) + { // prefer storing as work + myContact.workfax = r.ReadElementContentAsString(); + } + continue; + } + + // if we are still here, there is an attribute we don't know about + parsing_errors += "Unknown XML Attribute: " + r.GetAttribute("type") + "=" + r.ReadElementContentAsString(); + continue; } + if (parsing_errors != "") + { + MessageBox.Show("The following parsing errors have occured:" + Environment.NewLine + Environment.NewLine + parsing_errors); + } + + // Now all information should be stored in the array, so save it to the hashtable! addDataHash(ref duplicates, myContact); } @@ -1209,7 +1329,7 @@ private ReadDataReturn read_data_vCard(string filename, bool non_unicode) string currentline_for_crash = ""; try { - // replace escaped ":" characters, they should not be a problem when parsing (TODO: This could be a problem? Or maybe not? Do some additional tests sometime) + // replace escaped ":" characters, they should not be a problem when parsing string vParseLine = ParseLine.Replace("\\:", ":").Replace("\\\\", "\\").Replace("\\;", ",").Replace("\\,", ","); currentline_for_crash = vParseLine; @@ -1232,11 +1352,11 @@ private ReadDataReturn read_data_vCard(string filename, bool non_unicode) string vParseValue = vParseLine.Substring(vParseLine.IndexOf(":") + 1); - // TODO: If value is quoted printable we need to decode it first, I was unable to find proper working code so far :-( + // maybe someday ==> If value is quoted printable we need to decode it first, I was unable to find proper working code so far :-( // if (vParseOptions.ToUpper().Contains("CHARSET=UTF-8") && vParseOptions.ToUpper().Contains("ENCODING=QUOTED-PRINTABLE")) // { // MessageBox.Show("Now decoding:\r\n" + vParseValue + "\r\n" + UTF8Decode(vParseValue)); - // TODO, this doesn't really work yet + // this doesn't really work yet // } // MessageBox.Show(vParseLine + "\r\n==> ITEM: " + vParseItem + "\r\n==> OPT:" + vParseOptions + "\r\n==> VALUE: " + vParseValue); @@ -1534,7 +1654,8 @@ private ReadDataReturn read_data_vCard(string filename, bool non_unicode) if (crashed == true) { - // TODO: Hier wäre es schön ein Custom Form für die Fehlermeldung zu haben, in dem man auch Markieren&Kopieren in die Zwischenablage kann und das viel Text besser anzeigt (Textbox?) + // Hier wäre es natürlich schöner ein Custom Form für die Fehlermeldung zu haben, in dem man auch Markieren&Kopieren in die Zwischenablage kann und das viel Text besser anzeigt (Textbox?) + // habe aber keine Lust sowas zu implementieren momentan :-) MessageBox.Show("One or more lines in the vCard file could not be parsed and were ignored. If you think those lines were standard-compliant please report a bug in the IP-Phone-Forum with the vCard entry that caused the problem" + Environment.NewLine + Environment.NewLine + crashlog.ToString()); @@ -1728,17 +1849,54 @@ private ReadDataReturn read_data_genericCSV(string filename) return (new ReadDataReturn(duplicates)); } - private ReadDataReturn read_data_googleContacts() + private ReadDataReturn read_data_googleContacts(bool customfolder, string google_pass) { string duplicates = ""; - RequestSettings rs = new RequestSettings(this.ProductName + " v" + this.ProductVersion, g_login, g_pass); + RequestSettings rs = new RequestSettings(this.ProductName + " v" + this.ProductVersion, g_login, google_pass); rs.AutoPaging = true; // AutoPaging results in automatic paging in order to retrieve all contacts ContactsRequest cr = new ContactsRequest(rs); Feed f = cr.GetContacts(); - string der_token = cr.Service.QueryClientLoginToken(); + + // this is where the actual login/pass check happens + string der_token = ""; + try + { // we need the token for later (photo download) + der_token = cr.Service.QueryClientLoginToken(); + } + catch (Exception ex) + { + string exception_message = ex.ToString(); + if (exception_message.Contains(" at ") == true) + { + exception_message = exception_message.Substring(0, exception_message.IndexOf(" at ")); + } + + MessageBox.Show("Google login failed with the following exception:" + Environment.NewLine + Environment.NewLine + exception_message); + return (new ReadDataReturn(duplicates)); + } + + + List ListSelectedGroups = new List(); + + if (customfolder == true) + { + Feed g = cr.GetGroups(); + List ListAllGroups = new List(); + foreach (Group ge in g.Entries) { ListAllGroups.Add(new string[] { ge.Title, ge.Id}); } + + ImportGroupsChooser MyGoogleImportGroupsChooser = new ImportGroupsChooser("Please select the groups you want to import contacts from:", "Google Contact Group Chooser", ListAllGroups); + MyGoogleImportGroupsChooser.ShowDialog(); + + foreach (string[] z in MyGoogleImportGroupsChooser.resultList) + { // add group identifyer to selected groups list + ListSelectedGroups.Add(z[1]); + } + + MyGoogleImportGroupsChooser.Dispose(); + } foreach (Contact entry in f.Entries) { @@ -1753,17 +1911,67 @@ private ReadDataReturn read_data_googleContacts() myContact.company = (string.IsNullOrEmpty(entry.Organizations[0].Name)) ? string.Empty : entry.Organizations[0].Name; } + + + if (customfolder == true) + { + bool is_member_of_selected_group = false; + + foreach (GroupMembership memberGroup in entry.GroupMembership) + { + foreach (string currentGroup in ListSelectedGroups) + { + if (memberGroup.HRef == currentGroup) + { + is_member_of_selected_group = true; + break; // no need to check further groups, we already know we want this contact + } + } + } + + if (is_member_of_selected_group == false) + { + // MessageBox.Show("Skipping: " + myContact.lastname + "/" + myContact.firstname + "/" + entry.GroupMembership.Count.ToString()); + continue; + } + + } + + string google_main_number = ""; + foreach (PhoneNumber pnr in entry.Phonenumbers) { if (string.IsNullOrEmpty(pnr.Value) == true) { continue; } // if phone number string should be empty, go to next item if (pnr.Rel == ContactsRelationships.IsHome) { if (myContact.home == string.Empty) myContact.home = pnr.Value; } if (pnr.Rel == ContactsRelationships.IsWork) { if (myContact.work == string.Empty) myContact.work = pnr.Value; } + if (pnr.Rel == ContactsRelationships.IsMain) { google_main_number = pnr.Value; } if (pnr.Rel == ContactsRelationships.IsHomeFax) { if (myContact.homefax == string.Empty) myContact.homefax = pnr.Value; } if (pnr.Rel == ContactsRelationships.IsWorkFax) { if (myContact.workfax == string.Empty) myContact.workfax = pnr.Value; } if (pnr.Rel == ContactsRelationships.IsMobile) { if (myContact.mobile == string.Empty) myContact.mobile = pnr.Value; } } + + if (cfg_importOther == true && google_main_number != "") + { // if we are to import the other number and it is NOT empty, then + + if (combo_typeprefer.SelectedIndex == 0) + { // prefer storing as home + if (myContact.home == string.Empty) { myContact.home = google_main_number; } + else if (myContact.work == string.Empty) { myContact.work = google_main_number; } + } + if (combo_typeprefer.SelectedIndex == 1) + { // prefer storing as work + if (myContact.work == string.Empty) { myContact.work = google_main_number; } + else if (myContact.home == string.Empty) { myContact.home = google_main_number; } + } + } + + + + + + myContact.preferred = string.Empty; // Google Contacts has no preferred phone (at least not in the GUI, so we don't support it here) @@ -1844,6 +2052,10 @@ private void btn_save_Outlook_Click(object sender, EventArgs e) private void btn_save_FritzXML_Click(object sender, EventArgs e) { + // check whether the user had the shift key pressed while calling this function and store this in a variable for further use + bool shiftpressed_for_export_fax = false; + if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) { shiftpressed_for_export_fax = true; } + SaveFileDialog SaveXML_Dialog = new SaveFileDialog(); SaveXML_Dialog.Title = "Select the XML file you wish to create"; SaveXML_Dialog.DefaultExt = "xml"; @@ -1858,7 +2070,7 @@ private void btn_save_FritzXML_Click(object sender, EventArgs e) disable_buttons(true); - save_data_FritzXML(SaveXML_Dialog.FileName, myGroupDataHash); + save_data_FritzXML(SaveXML_Dialog.FileName, myGroupDataHash, shiftpressed_for_export_fax); // and reenable user interface disable_buttons(false); @@ -1891,6 +2103,32 @@ private void btn_save_vCard_Click(object sender, EventArgs e) } // just click handler + + private void btn_save_vCard_Gigaset_Click(object sender, EventArgs e) + { + SaveFileDialog SaveVCF_Dialog = new SaveFileDialog(); + SaveVCF_Dialog.Title = "Select the Gigaset vCard file you wish to create"; + SaveVCF_Dialog.DefaultExt = "vcf"; + SaveVCF_Dialog.Filter = "VCF files (*.vcf)|*.vcf"; + SaveVCF_Dialog.InitialDirectory = Environment.SpecialFolder.Desktop.ToString(); + SaveVCF_Dialog.FileName = "Simplified vCard Export for Gigaset"; + + if (SaveVCF_Dialog.ShowDialog() == DialogResult.Cancel) + { + return; + } + + disable_buttons(true); + + save_data_vCard_Gigaset(SaveVCF_Dialog.FileName, myGroupDataHash); + + // and reenable user interface + disable_buttons(false); + + } // just click handler + + + private void btn_save_FritzAdr_Click(object sender, EventArgs e) { // check whether the user had the shift key pressed while calling this function and store this in a variable for further use @@ -2075,28 +2313,154 @@ private void btn_save_Auerswald_Click(object sender, EventArgs e) // just clic private void btn_save_googleContacts_Click(object sender, EventArgs e) // just click handler { disable_buttons(true); - save_data_googleContacts(myGroupDataHash); + + if (g_login == string.Empty) + { + MessageBox.Show("Please configure Google login in the configuration menu first!"); + disable_buttons(false); + return; + } + + string custom_google_pass = ""; + if (g_pass != string.Empty) + { + custom_google_pass = g_pass; + } + else + { + SimpleInputDialog MySimpleInputDialog = new SimpleInputDialog("Please enter the Google password for login " + g_login + ":", "Enter Google Password", false, true); + MySimpleInputDialog.ShowDialog(); + custom_google_pass = MySimpleInputDialog.resultstring; + MySimpleInputDialog.Dispose(); + } + + save_data_googleContacts(myGroupDataHash, custom_google_pass); + disable_buttons(false); + } + + private void btn_save_panasonicCSV_Click(object sender, EventArgs e) + { + + SaveFileDialog SaveXML_Dialog = new SaveFileDialog(); + SaveXML_Dialog.Title = "Select the CSV file you wish to create"; + SaveXML_Dialog.DefaultExt = "phb"; + SaveXML_Dialog.Filter = "PHB files (*.phb)|*.phb"; + SaveXML_Dialog.InitialDirectory = Environment.SpecialFolder.Desktop.ToString(); + SaveXML_Dialog.FileName = "PanasonicExport"; + + if (SaveXML_Dialog.ShowDialog() == DialogResult.Cancel) + { + return; + } + + disable_buttons(true); + save_data_PanasonicCSV(SaveXML_Dialog.FileName, myGroupDataHash); + + // and reenable user interface disable_buttons(false); } - private void save_data_googleContacts(System.Collections.Hashtable workDataHash) + private void save_data_PanasonicCSV(string filename, System.Collections.Hashtable workDataHash) { // get the country ID from the combobox or from user input string country_id = RetrieveCountryID(combo_prefix.SelectedItem.ToString()); - RequestSettings rs = new RequestSettings(this.ProductName + " v" + this.ProductVersion, g_login, g_pass); + // process with exporting + StringBuilder resultSB = new StringBuilder(); + + // write the header for panasonic + resultSB.Append("; Panasonic Communications Co., Ltd. Phonebook DECT Version 2.00\r\n"); + + System.Collections.Hashtable MySaveDataHash = new System.Collections.Hashtable(); + + foreach (System.Collections.DictionaryEntry contactHash in workDataHash) + { + // extract GroupDataList from hashtable contents + GroupDataContact contactData = (GroupDataContact)contactHash.Value; + + // clean up phone number + string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; + string CleanUpNumberHome = CleanUpNumber(contactData.home, country_id, prefix_string); + string CleanUpNumberWork = CleanUpNumber(contactData.work, country_id, prefix_string); + string CleanUpNumberMobile = CleanUpNumber(contactData.mobile, country_id, prefix_string); + + // check if all relevant clean phone numbers for this export here are empty + if (CleanUpNumberHome == string.Empty && CleanUpNumberWork == string.Empty && CleanUpNumberMobile == string.Empty) + { continue; /* if yes, abort this foreach loop and contine to the next one */ } + + + // this is the list of numbers for the contact + List numbers = new List(); + + if (CleanUpNumberHome != "") { numbers.Add(CleanUpNumberHome); } + if (CleanUpNumberWork != "") { numbers.Add(CleanUpNumberWork); } + if (CleanUpNumberMobile != "") { numbers.Add(CleanUpNumberMobile); } + + // if there are no phone numbers remaining after cleanup, abort this loop + if (numbers.Count == 0) { MessageBox.Show("Skipping " + contactData.combinedname); continue; } + + string name_home = LimitNameLength(contactData.combinedname, 16, false, ""); + string sep = ","; + + //maybe one day add possibility for menaingful mapping of groups. use constant 1 for the moment + string contactgroup = "1"; + + try + { + MySaveDataHash.Add(name_home, "\"" + name_home + "\"" + sep + contactgroup + sep + numbers.Aggregate((current, next) => current + sep + next) + "\n"); + } + catch (ArgumentException) // unable to add to MySaveFaxDataHash, must mean that something with (modified) contactData.combinedname is already in there! + { + MessageBox.Show("Unable to export the shortened entry \"" + name_home + "\",\r\nanother entry with this name already exists!\r\n\r\nIgnoring duplicate for contact source: " + contactData.combinedname); + } + + } // end of foreach loop for the contacts + + // retrieve stuff from hastable and put in resultstring: + foreach (System.Collections.DictionaryEntry saveDataHash in MySaveDataHash) + { + resultSB.Append((string)saveDataHash.Value); + } + + // actually write the file to disk + System.IO.File.WriteAllText(filename, resultSB.ToString(), Encoding.GetEncoding("ISO-8859-1")); + } + + private void save_data_googleContacts(System.Collections.Hashtable workDataHash, string google_pass) + { + // get the country ID from the combobox or from user input + string country_id = RetrieveCountryID(combo_prefix.SelectedItem.ToString()); + + RequestSettings rs = new RequestSettings(this.ProductName + " v" + this.ProductVersion, g_login, google_pass); rs.AutoPaging = true; // AutoPaging results in automatic paging in order to retrieve all contacts ContactsRequest cr = new ContactsRequest(rs); + // this is where the actual login/pass check happens + try + { // this line does absolutely nothing here (we don't save the result), but it checks if l/p is ok so we don't run into trouble later! + cr.Service.QueryClientLoginToken(); + } + catch (Exception ex) + { + string exception_message = ex.ToString(); + if (exception_message.Contains(" at ") == true) + { + exception_message = exception_message.Substring(0, exception_message.IndexOf(" at ")); + } + + MessageBox.Show("Google login failed with the following exception:" + Environment.NewLine + Environment.NewLine + exception_message); + return; + } + + + + // List that holds the batch request entries. List requestFeed = new List(); // iterate through the contacts in workDatahash and save them to the selected Outlook Folder - // int count = 0; TODO WEG DAMIT foreach (System.Collections.DictionaryEntry contactHash in workDataHash) { - // if (count > 3) { continue; } TODO WEG DAMIT - // extract GroupDataList from hashtable contents GroupDataContact contactData = (GroupDataContact)contactHash.Value; @@ -2122,7 +2486,7 @@ private void save_data_googleContacts(System.Collections.Hashtable workDataHash) newEntry.Name = new Name() { FullName = contactData.combinedname, GivenName = contactData.firstname, FamilyName = contactData.lastname, }; // Set the contact's name. if (contactData.company != "") newEntry.Organizations.Add(new Organization() { Primary = true, Rel = Google.GData.Extensions.ContactsRelationships.IsWork, Name = contactData.company }); - if (contactData.email != "") newEntry.Emails.Add(new EMail() { Primary = true, Rel = ContactsRelationships.IsHome, Address = contactData.email }); // Set the contact's e-mail addresses. // TODO - home or work, da gibts ein preset? + if (contactData.email != "") newEntry.Emails.Add(new EMail() { Primary = true, Rel = ContactsRelationships.IsHome, Address = contactData.email }); // Set the contact's e-mail addresses. // primary phone number bool prefer_homephone = false; @@ -2156,10 +2520,9 @@ private void save_data_googleContacts(System.Collections.Hashtable workDataHash) requestFeed.Add(newEntry); - // count++; TODO WEG DAMIT - } // end of foreach loop for the contacts + // Submit the batch request to the server. List uploadFeed = new List(); @@ -2184,11 +2547,11 @@ private void save_data_googleContacts(System.Collections.Hashtable workDataHash) uploadFeed.Clear(); // tell the user what has been done - MessageBox.Show((i+1).ToString() + "/" + requestFeed.Count + " contacts have been written to the gMail Folder 'Other Contacts'!" + Environment.NewLine + responseData.ToString()); + MessageBox.Show((i+1).ToString() + "/" + requestFeed.Count + " contacts have been written to the Google Folder 'Other Contacts'!" + Environment.NewLine + responseData.ToString()); } } - } + } private void save_data_Outlook(System.Collections.Hashtable workDataHash) { @@ -2270,7 +2633,7 @@ private void save_data_Outlook(System.Collections.Hashtable workDataHash) MessageBox.Show(count + " contacts have been written to the selected Outlook folder!" + Environment.NewLine); } - private void save_data_FritzXML(string filename, System.Collections.Hashtable workDataHash) + private void save_data_FritzXML(string filename, System.Collections.Hashtable workDataHash, bool export_fax) { // get the country ID from the combobox or from user input string country_id = RetrieveCountryID(combo_prefix.SelectedItem.ToString()); @@ -2295,6 +2658,8 @@ private void save_data_FritzXML(string filename, System.Collections.Hashtable wo // initialize hashtable to store generated data results System.Collections.Hashtable MySaveDataHash = new System.Collections.Hashtable(); + bool pics_actually_exported = false; + foreach (System.Collections.DictionaryEntry contactHash in workDataHash) { StringBuilder contactSB = new StringBuilder(); @@ -2302,22 +2667,19 @@ private void save_data_FritzXML(string filename, System.Collections.Hashtable wo // extract GroupDataList from hashtable contents GroupDataContact contactData = (GroupDataContact)contactHash.Value; - // check if all relevant phone numbers for this export here are empty - if (contactData.home == string.Empty && contactData.work == string.Empty && contactData.mobile == string.Empty) - { continue; /* if yes, abort this foreach loop and contine to the next one */ } - - string SaveAsName = contactData.combinedname; - - // limit to 32 chars - SaveAsName = LimitNameLength(SaveAsName, 32, false, ""); - - // replace "&","<",">", """ - SaveAsName = Do_XML_replace(SaveAsName); - // clean up phone number string CleanUpNumberHome = CleanUpNumber(contactData.home, country_id, contactData.FRITZprefix); string CleanUpNumberWork = CleanUpNumber(contactData.work, country_id, contactData.FRITZprefix); string CleanUpNumberMobile = CleanUpNumber(contactData.mobile, country_id, contactData.FRITZprefix); + string CleanUpNumberHomeFax = CleanUpNumber(contactData.homefax, country_id, contactData.FRITZprefix); + string CleanUpNumberWorkFax = CleanUpNumber(contactData.workfax, country_id, contactData.FRITZprefix); + + // check if all relevant phone numbers for this export here are empty + if (CleanUpNumberHome == string.Empty && CleanUpNumberWork == string.Empty && CleanUpNumberMobile == string.Empty) + { continue; /* if yes, abort this foreach loop and contine to the next one */ } + + // limit to 32 chars and replace "&","<",">", """ + string SaveAsName = Do_XML_replace(LimitNameLength(contactData.combinedname, 32, false, "")); // write contact header @@ -2332,6 +2694,8 @@ private void save_data_FritzXML(string filename, System.Collections.Hashtable wo string picfile = System.IO.Path.ChangeExtension(System.IO.Path.GetRandomFileName(), "jpg"); writeByteArrayToFile(contactData.jpeg, System.IO.Path.Combine(pic_export_path, picfile)); imageURLstring = "" + textBox_PicPath.Text + picfile + "\n"; + + pics_actually_exported = true; } contactSB.Append("\n" + VIPid + "\n\n" + SaveAsName + "\n" + imageURLstring + "\n\n"); @@ -2412,10 +2776,21 @@ private void save_data_FritzXML(string filename, System.Collections.Hashtable wo } else { fritzXMLmobile = "\n"; } + string fritzXMLfax = ""; + + // add fax phone number + if (export_fax == true && CleanUpNumberHomeFax != "") + { + { fritzXMLfax += "" + CleanUpNumberHomeFax + "\n"; } + } + if (export_fax == true && CleanUpNumberWorkFax != "") + { + { fritzXMLfax += "" + CleanUpNumberWorkFax + "\n"; } + } // actually add stuff we have prepared above - if (cfg_fritzWorkFirst == false) - { + if (combo_typeprefer.SelectedIndex == 0) + { // preferred is home for import/export contactSB.Append(fritzXMLhome); contactSB.Append(fritzXMLwork); } @@ -2426,6 +2801,7 @@ private void save_data_FritzXML(string filename, System.Collections.Hashtable wo } contactSB.Append(fritzXMLmobile); + contactSB.Append(fritzXMLfax); @@ -2435,7 +2811,7 @@ private void save_data_FritzXML(string filename, System.Collections.Hashtable wo // depending on whether an eMail exists, add email or not if (contactData.email != "") { - contactSB.Append("" + contactData.email + ""); + contactSB.Append("" + Do_XML_replace(contactData.email) + ""); contactSB.Append("\n"); } else @@ -2454,7 +2830,7 @@ private void save_data_FritzXML(string filename, System.Collections.Hashtable wo foreach (System.Collections.DictionaryEntry saveDataHash in MySaveDataHash) { resultSB.Append((string)saveDataHash.Value); } - // write file footer with AVM HD Music test stuff, currently not added. Not sure if thats a good idea to add this always. + // write file footer with AVM HD Music test stuff, currently not added. Not sure if it's a good idea to add this always. // resultstring += "~AVM-HD-Musik200@hd-telefonie.avm.de~AVM-HD-Sprache100@hd-telefonie.avm.de"; resultSB.Append("\n"); @@ -2463,9 +2839,49 @@ private void save_data_FritzXML(string filename, System.Collections.Hashtable wo // tell the user this has been done string errorwarning = ""; - if (MySaveDataHash.Count > 300) { errorwarning = Environment.NewLine + "Warning: Over 300 contacts have been exported! This might or might not be officially supported by AVM's Fritz!Box and may cause problems. Proceed with care!"; } + if (MySaveDataHash.Count > 300) { errorwarning = Environment.NewLine + "Warning: Over 300 contacts have been exported! This might or might not be officially supported by AVM's Fritz!Box and may cause problems."; } MessageBox.Show(MySaveDataHash.Count + " contacts written to " + filename + " !" + Environment.NewLine + errorwarning); + if (textBox_PicPath.Text.Contains("fonpix-custom") == true && pics_actually_exported == true) + { + string targetPath = @"\\fritz.nas\FRITZ.NAS\FRITZ\fonpix-custom\"; + + DialogResult dialogResult = MessageBox.Show("Do you want CCW to try copying the contact pictures to " + targetPath + " ?" + Environment.NewLine + "This can only work if your windows user already has access rights to this network share!" + Environment.NewLine + "Existing files in this directory will be removed!", "Try copying pictures to \\\\FRITZ.NAS\\ ?", MessageBoxButtons.YesNo); + + try + { + + if (dialogResult == DialogResult.Yes) + { + + if (!System.IO.Directory.Exists(targetPath)) + { + System.IO.Directory.CreateDirectory(targetPath); + } + + foreach (FileInfo f in new DirectoryInfo(targetPath).GetFiles("*.jpg")) + { + f.Delete(); + } + + foreach (FileInfo f in new DirectoryInfo(pic_export_path).GetFiles("*.jpg")) + { + f.CopyTo(System.IO.Path.Combine(targetPath, f.Name), true); + } + + } + else if (dialogResult == DialogResult.No) + { + //do something else + } + } + catch (Exception e) + { + MessageBox.Show("Copying failed with exception: " + e.ToString()); + } + + } + } private void save_data_vCard(string filename, System.Collections.Hashtable workDataHash, bool export_only_phone) @@ -2492,14 +2908,14 @@ private void save_data_vCard(string filename, System.Collections.Hashtable workD string CleanUpNumberMobile = CleanUpNumber(contactData.mobile, country_id, prefix_string); // clean up the rest of the data - string CleanUpStreet = contactData.street.Replace("\\", "\\\\").Replace(";", "\\;").Replace(",", "\\,"); - string CleanUpCity = contactData.city.Replace("\\", "\\\\").Replace(";", "\\;").Replace(",", "\\,"); - string CleanUpZIP = contactData.zip.Replace("\\", "\\\\").Replace(";", "\\;").Replace(",", "\\,"); - string CleanUpeMail = contactData.email.Replace("\\", "\\\\").Replace(";", "\\;").Replace(",", "\\,"); - string CleanUpFirstName = contactData.firstname.Replace("\\", "\\\\").Replace(";", "\\;").Replace(",", "\\,"); - string CleanUpLastName = contactData.lastname.Replace("\\", "\\\\").Replace(";", "\\;").Replace(",", "\\,"); - string CleanUpCompany = contactData.company.Replace("\\", "\\\\").Replace(";", "\\;").Replace(",", "\\,"); - string CleanUpCombined = contactData.combinedname.Replace("\\", "\\\\").Replace(";", "\\;").Replace(",", "\\,"); + string CleanUpStreet = Do_VCARD_replace(contactData.street); + string CleanUpCity = Do_VCARD_replace(contactData.city); + string CleanUpZIP = Do_VCARD_replace(contactData.zip); + string CleanUpeMail = Do_VCARD_replace(contactData.email); + string CleanUpFirstName = Do_VCARD_replace(contactData.firstname); + string CleanUpLastName = Do_VCARD_replace(contactData.lastname); + string CleanUpCompany = Do_VCARD_replace(contactData.company); + string CleanUpCombined = Do_VCARD_replace(contactData.combinedname); // if we only wish to export phone numbers => check if all relevant phone fields for this export are empty if (export_only_phone == true && (CleanUpNumberHome == string.Empty && CleanUpNumberWork == string.Empty && CleanUpNumberMobile == string.Empty)) @@ -2596,7 +3012,101 @@ private void save_data_vCard(string filename, System.Collections.Hashtable workD } // actually write the file to disk - System.IO.File.WriteAllText(filename, resultstring.ToString(), Encoding.Unicode); + System.IO.File.WriteAllText(filename, resultstring.ToString(), Encoding.UTF8); + } + + private void save_data_vCard_Gigaset(string filename, System.Collections.Hashtable workDataHash) + { + // get the country ID from the combobox or from user input + string country_id = RetrieveCountryID(combo_prefix.SelectedItem.ToString()); + + System.Collections.Hashtable MySaveDataHash = new System.Collections.Hashtable(); + foreach (System.Collections.DictionaryEntry contactHash in workDataHash) + { + // process with exporting + StringBuilder sb_resultstring = new StringBuilder(); + + // extract GroupDataList from hashtable contents + GroupDataContact contactData = (GroupDataContact)contactHash.Value; + + string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; + + // clean up phone numbers + string CleanUpNumberHome = CleanUpNumber(contactData.home, country_id, prefix_string); + string CleanUpNumberWork = CleanUpNumber(contactData.work, country_id, prefix_string); + string CleanUpNumberMobile = CleanUpNumber(contactData.mobile, country_id, prefix_string); + + // clean up the rest of the data + string CleanUpeMail = Do_VCARD_replace(contactData.email); + + // limit to 16 chars (maximum for Gigaset DX600A) + + string CleanUpFirstName = Do_VCARD_replace_Gigaset(LimitNameLength(contactData.firstname, 16, false, "")); + string CleanUpLastName = Do_VCARD_replace_Gigaset(LimitNameLength(contactData.lastname, 16, false, "")); + string CleanUpCombined = Do_VCARD_replace_Gigaset(LimitNameLength(contactData.combinedname, 16, false, "")); + + // we only wish to export phone numbers for Gigaset (plus email) => check if all relevant phone fields for this export are empty and quit if so + if (CleanUpNumberHome == string.Empty && CleanUpNumberWork == string.Empty && CleanUpNumberMobile == string.Empty) + { + // MessageBox.Show("Contact |" + CleanUpCombined + "| ignored, due to missing numbers"); + // if yes, abort this foreach loop and contine to the next one + continue; + } + + sb_resultstring.AppendLine("BEGIN:VCARD"); + sb_resultstring.AppendLine("VERSION:2.1"); + + // if we have chosen to not have a company or if the company string is empty, export lastname and firstname separately + if (combo_namestyle.SelectedItem.ToString().Contains("Company") == true && contactData.company != "") + { + sb_resultstring.AppendLine("N:" + CleanUpCombined + ";"); + } + else + { + sb_resultstring.AppendLine("N:" + CleanUpLastName + ";" + CleanUpFirstName); + } + + + // save home phone number + if (CleanUpNumberHome != string.Empty) + { + { sb_resultstring.AppendLine("TEL;HOME:" + CleanUpNumberHome); } + } + + // save work phone number + if (CleanUpNumberWork != string.Empty) + { + { sb_resultstring.AppendLine("TEL;WORK:" + CleanUpNumberWork); } + } + + // save mobile phone number + if (CleanUpNumberMobile != string.Empty) + { + { sb_resultstring.AppendLine("TEL;CELL:" + CleanUpNumberMobile); } + } + + // save email + if (CleanUpeMail != string.Empty) + { + sb_resultstring.AppendLine("EMAIL:" + CleanUpeMail); + } + + sb_resultstring.AppendLine("END:VCARD"); + + // add contact line + add_nr_to_hash(ref MySaveDataHash, contactData.combinedname, sb_resultstring.ToString(), contactData.combinedname); + + } // end of foreach loop for the contacts + + StringBuilder resultstring = new StringBuilder(); + // retrieve stuff from hastable and put in resultstring: + foreach (System.Collections.DictionaryEntry saveDataHash in MySaveDataHash) + { + resultstring.Append((string)saveDataHash.Value); + } + + // actually write the file to disk + System.IO.File.WriteAllText(filename, resultstring.ToString(), utf8WithoutBom); } private void save_data_FritzAdress(string filename, System.Collections.Hashtable workDataHash, bool only_export_fax) @@ -2618,22 +3128,22 @@ private void save_data_FritzAdress(string filename, System.Collections.Hashtable // extract GroupDataList from hashtable contents GroupDataContact contactData = (GroupDataContact)contactHash.Value; - // check if both relevant fax fields for this export are empty - AND we only wish to export those who have faxnumbers - if (contactData.homefax == string.Empty && contactData.workfax == string.Empty && (only_export_fax == true)) - { - // if yes, abort this foreach loop and contine to the next one - continue; - } - - string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; - // clean up phone numbers + string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; string CleanUpNumberHome = CleanUpNumber(contactData.home, country_id, prefix_string); string CleanUpNumberWork = CleanUpNumber(contactData.work, country_id, prefix_string); string CleanUpNumberHomefax = CleanUpNumber(contactData.homefax, country_id, prefix_string); string CleanUpNumberWorkfax = CleanUpNumber(contactData.workfax, country_id, prefix_string); string CleanUpNumberMobile = CleanUpNumber(contactData.mobile, country_id, prefix_string); + // check if both relevant fax fields for this export are empty - AND we only wish to export those who have faxnumbers + if (CleanUpNumberHomefax == string.Empty && CleanUpNumberWorkfax == string.Empty && (only_export_fax == true)) + { + // if yes, abort this foreach loop and contine to the next one + continue; + } + + string[,] save_iterate_array; @@ -2705,27 +3215,23 @@ private void save_data_SnomCSV7(string filename, System.Collections.Hashtable wo // extract GroupDataList from hashtable contents GroupDataContact contactData = (GroupDataContact)contactHash.Value; - // check if all relevant phone numbers for this export here are empty - if (contactData.home == string.Empty && contactData.work == string.Empty && contactData.mobile == string.Empty) - { continue; /* if yes, abort this foreach loop and contine to the next one */ } - - string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; - // clean up phone number + string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; string CleanUpNumberHome = CleanUpNumber(contactData.home, country_id, prefix_string); string CleanUpNumberWork = CleanUpNumber(contactData.work, country_id, prefix_string); string CleanUpNumberMobile = CleanUpNumber(contactData.mobile, country_id, prefix_string); + + // check if all relevant phone numbers for this export here are empty + if (CleanUpNumberHome == string.Empty && CleanUpNumberWork == string.Empty && CleanUpNumberMobile == string.Empty) + { continue; /* if yes, abort this foreach loop and contine to the next one */ } + // add privat/gesch. to name if necessary (if two entries for one name necessary) - string name_home = contactData.combinedname; - string name_work = contactData.combinedname; - string name_mobile = contactData.combinedname; - bool separate_entries = CheckIfSeparateEntries(CleanUpNumberHome, CleanUpNumberWork, CleanUpNumberMobile); - - name_home = LimitNameLength(name_home, 31, separate_entries, " H"); - name_work = LimitNameLength(name_work, 31, separate_entries, " W"); - name_mobile = LimitNameLength(name_mobile, 31, separate_entries, " M"); + + string name_home = LimitNameLength(contactData.combinedname, 31, separate_entries, " H"); + string name_work = LimitNameLength(contactData.combinedname, 31, separate_entries, " W"); + string name_mobile = LimitNameLength(contactData.combinedname, 31, separate_entries, " M"); // write contact line if not empty if (CleanUpNumberHome != "") add_nr_to_hash(ref MySaveDataHash, name_home, "\"" + name_home + "\",\"" + CleanUpNumberHome + "\"\r\n", contactData.combinedname); @@ -2742,7 +3248,6 @@ private void save_data_SnomCSV7(string filename, System.Collections.Hashtable wo } // actually write the file to disk - System.Text.Encoding utf8WithoutBom = new System.Text.UTF8Encoding(false); System.IO.File.WriteAllText(filename, resultSB.ToString(), utf8WithoutBom); } @@ -2756,22 +3261,23 @@ private void save_data_SnomCSV8(string filename, System.Collections.Hashtable wo System.Collections.Hashtable MySaveDataHash = new System.Collections.Hashtable(); + int master_id = 100000; + foreach (System.Collections.DictionaryEntry contactHash in workDataHash) { // extract GroupDataList from hashtable contents GroupDataContact contactData = (GroupDataContact)contactHash.Value; - // check if all relevant phone numbers for this export here are empty - if (contactData.home == string.Empty && contactData.work == string.Empty && contactData.mobile == string.Empty) - { continue; /* if yes, abort this foreach loop and contine to the next one */ } - - string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; - // clean up phone number + string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; string CleanUpNumberHome = CleanUpNumber(contactData.home, country_id, prefix_string); string CleanUpNumberWork = CleanUpNumber(contactData.work, country_id, prefix_string); string CleanUpNumberMobile = CleanUpNumber(contactData.mobile, country_id, prefix_string); + // check if all relevant phone numbers for this export here are empty + if (CleanUpNumberHome == string.Empty && CleanUpNumberWork == string.Empty && CleanUpNumberMobile == string.Empty) + { continue; /* if yes, abort this foreach loop and contine to the next one */ } + // limit full name to 31 chars string name_contact = LimitNameLength(contactData.combinedname, 31, false, ""); @@ -2872,8 +3378,10 @@ private void save_data_SnomCSV8(string filename, System.Collections.Hashtable wo if (phone_numbers > 1) { + master_id = master_id + 1; + out_string += "\"" + name_contact - + sep + phones[0, 1] + + sep + master_id.ToString("D8") + sep + "MASTER" + sep + string.Empty + sep + contactData.firstname @@ -2898,7 +3406,7 @@ private void save_data_SnomCSV8(string filename, System.Collections.Hashtable wo + sep + phones[i, 2] // add vip if VIP + sep + string.Empty + sep + "Member_Alias" - + sep + phones[0, 1] // main number + + sep + master_id.ToString("D8") // master id for association with main contact + sep + string.Empty + sep + string.Empty + sep + string.Empty @@ -2936,7 +3444,7 @@ private void save_data_SnomCSV8(string filename, System.Collections.Hashtable wo } // write contact line - if (CleanUpNumberHome != "") add_nr_to_hash(ref MySaveDataHash, name_contact, out_string, contactData.combinedname); + add_nr_to_hash(ref MySaveDataHash, name_contact, out_string, contactData.combinedname); } // end of foreach loop for the contacts @@ -2947,7 +3455,6 @@ private void save_data_SnomCSV8(string filename, System.Collections.Hashtable wo } // actually write the file to disk - System.Text.Encoding utf8WithoutBom = new System.Text.UTF8Encoding(false); System.IO.File.WriteAllText(filename, resultSB.ToString(), utf8WithoutBom); } @@ -2970,16 +3477,15 @@ private void save_data_TalkSurfCSV(string filename, System.Collections.Hashtable // extract GroupDataList from hashtable contents GroupDataContact contactData = (GroupDataContact)contactHash.Value; - // check if all relevant phone numbers for this export here are empty - if (contactData.home == string.Empty && contactData.work == string.Empty && contactData.mobile == string.Empty) - { continue; /* if yes, abort this foreach loop and contine to the next one */ } - - string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; - // clean up phone number + string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; string CleanUpNumberHome = CleanUpNumber(contactData.home, country_id, prefix_string); string CleanUpNumberWork = CleanUpNumber(contactData.work, country_id, prefix_string); string CleanUpNumberMobile = CleanUpNumber(contactData.mobile, country_id, prefix_string); + + // check if all relevant phone numbers for this export here are empty + if (CleanUpNumberHome == string.Empty && CleanUpNumberWork == string.Empty && CleanUpNumberMobile == string.Empty) + { continue; /* if yes, abort this foreach loop and contine to the next one */ } // add privat/gesch. to name if necessary (if seperate entries for one name necessary) - and remove "," because talk&surf can't handle it properly string name_home = contactData.combinedname.Replace(",", ""); @@ -3025,17 +3531,16 @@ private void save_data_AastraCSV(string filename, System.Collections.Hashtable w // extract GroupDataList from hashtable contents GroupDataContact contactData = (GroupDataContact)contactHash.Value; - // check if all relevant phone numbers for this export here are empty - if (contactData.home == string.Empty && contactData.work == string.Empty && contactData.mobile == string.Empty) - { continue; /* if yes, abort this foreach loop and contine to the next one */ } - - string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; - // clean up phone number + string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; string CleanUpNumberHome = CleanUpNumber(contactData.home, country_id, prefix_string); string CleanUpNumberWork = CleanUpNumber(contactData.work, country_id, prefix_string); string CleanUpNumberMobile = CleanUpNumber(contactData.mobile, country_id, prefix_string); + // check if all relevant phone numbers for this export here are empty + if (CleanUpNumberHome == string.Empty && CleanUpNumberWork == string.Empty && CleanUpNumberMobile == string.Empty) + { continue; /* if yes, abort this foreach loop and contine to the next one */ } + bool separate_entries = CheckIfSeparateEntries(CleanUpNumberHome, CleanUpNumberWork, CleanUpNumberMobile); // limit to 31 chars @@ -3057,7 +3562,6 @@ private void save_data_AastraCSV(string filename, System.Collections.Hashtable w } // actually write the file to disk - System.Text.Encoding utf8WithoutBom = new System.Text.UTF8Encoding(false); System.IO.File.WriteAllText(filename, resultSB.ToString(), utf8WithoutBom); } @@ -3082,17 +3586,16 @@ private void save_data_AuerswaldCSV(string filename, System.Collections.Hashtabl // extract GroupDataList from hashtable contents GroupDataContact contactData = (GroupDataContact)contactHash.Value; - // check if all relevant phone numbers for this export here are empty - if (contactData.home == string.Empty && contactData.work == string.Empty && contactData.mobile == string.Empty) - { continue; /* if yes, abort this foreach loop and contine to the next one */ } - - string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; - // clean up phone number + string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; string CleanUpNumberHome = CleanUpNumber(contactData.home, country_id, prefix_string); string CleanUpNumberWork = CleanUpNumber(contactData.work, country_id, prefix_string); string CleanUpNumberMobile = CleanUpNumber(contactData.mobile, country_id, prefix_string); + // check if all relevant phone numbers for this export here are empty + if (CleanUpNumberHome == string.Empty && CleanUpNumberWork == string.Empty && CleanUpNumberMobile == string.Empty) + { continue; /* if yes, abort this foreach loop and contine to the next one */ } + string qd_home = ""; string qd_work = ""; string qd_mobile = ""; @@ -3175,9 +3678,6 @@ private void save_data_GrandstreamGXV(string filename, System.Collections.Hashta // extract GroupDataList from hashtable contents GroupDataContact contactData = (GroupDataContact)contactHash.Value; - // check if all relevant phone numbers for this export here are empty - if (contactData.home == string.Empty && contactData.work == string.Empty && contactData.mobile == string.Empty) - { continue; /* if yes, abort this foreach loop and contine to the next one */ } // clean up phone number string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; @@ -3185,16 +3685,30 @@ private void save_data_GrandstreamGXV(string filename, System.Collections.Hashta string CleanUpNumberWork = CleanUpNumber(contactData.work, country_id, prefix_string); string CleanUpNumberMobile = CleanUpNumber(contactData.mobile, country_id, prefix_string); - // limit to 32 chars (unsure if correct value) - string SaveAsName = LimitNameLength(contactData.combinedname, 32, false, ""); + // check if all relevant phone numbers for this export here are empty + if (CleanUpNumberHome == string.Empty && CleanUpNumberWork == string.Empty && CleanUpNumberMobile == string.Empty) + { continue; /* if yes, abort this foreach loop and contine to the next one */ } - // XML replacements - SaveAsName = Do_XML_replace(SaveAsName); - string str_1_name = " \n" + // limit to 32 chars (unsure if correct value) and XML replacements + string SaveAsName = Do_XML_replace(LimitNameLength(contactData.combinedname, 32, false, "")); + string FirstName = Do_XML_replace(LimitNameLength(contactData.firstname, 32, false, "")); + string LastName = Do_XML_replace(LimitNameLength(contactData.lastname, 32, false, "")); + + string str_1_name = ""; + // if we have chosen to not have a company or if the company string is empty, export lastname and firstname separately + if (combo_namestyle.SelectedItem.ToString().Contains("Company") == true && contactData.company != "") + { + str_1_name = " \n" + " \n" + " " + SaveAsName + "\n"; - + } + else + { + str_1_name = " \n" + + " " + FirstName + "\n" + + " " + LastName + "\n"; + } string str_3_end = " \n"; @@ -3262,25 +3776,21 @@ private void save_data_GrandstreamGXP(string filename, System.Collections.Hashta // initialize hashtable to store generated data results System.Collections.Hashtable MySaveDataHash = new System.Collections.Hashtable(); - int num_export = 0; - int limit_export = 250; // this value was determined using trial and error, 250 worked, 300 didn't, even larger numbers crashed the phone completely - foreach (System.Collections.DictionaryEntry contactHash in workDataHash) { // extract GroupDataList from hashtable contents GroupDataContact contactData = (GroupDataContact)contactHash.Value; - // check if all relevant phone numbers for this export here are empty - if (contactData.home == string.Empty && contactData.work == string.Empty && contactData.mobile == string.Empty) - { continue; /* if yes, abort this foreach loop and contine to the next one */ } - - string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; - // clean up phone number + string prefix_string = (cfg_prefixNONFB == true) ? contactData.FRITZprefix : string.Empty; string CleanUpNumberHome = CleanUpNumber(contactData.home, country_id, prefix_string); string CleanUpNumberWork = CleanUpNumber(contactData.work, country_id, prefix_string); string CleanUpNumberMobile = CleanUpNumber(contactData.mobile, country_id, prefix_string); + // check if all relevant phone numbers for this export here are empty + if (CleanUpNumberHome == string.Empty && CleanUpNumberWork == string.Empty && CleanUpNumberMobile == string.Empty) + { continue; /* if yes, abort this foreach loop and contine to the next one */ } + bool separate_entries = CheckIfSeparateEntries(CleanUpNumberHome, CleanUpNumberWork, CleanUpNumberMobile); // add Home/Work/Mobile to name if separate entries for one name necessary and limit to 20 chars @@ -3305,14 +3815,14 @@ private void save_data_GrandstreamGXP(string filename, System.Collections.Hashta + " \n"; // write contact line if not empty - if (CleanUpNumberHome != "" && num_export < limit_export) - { add_nr_to_hash(ref MySaveDataHash, name_home, str_1 + name_home + str_2 + CleanUpNumberHome + str_3, contactData.combinedname); num_export++; } + if (CleanUpNumberHome != "") + { add_nr_to_hash(ref MySaveDataHash, name_home, str_1 + name_home + str_2 + CleanUpNumberHome + str_3, contactData.combinedname); } - if (CleanUpNumberWork != "" && num_export < limit_export) - { add_nr_to_hash(ref MySaveDataHash, name_work, str_1 + name_work + str_2 + CleanUpNumberWork + str_3, contactData.combinedname); num_export++; } + if (CleanUpNumberWork != "") + { add_nr_to_hash(ref MySaveDataHash, name_work, str_1 + name_work + str_2 + CleanUpNumberWork + str_3, contactData.combinedname); } - if (CleanUpNumberMobile != "" && num_export < limit_export) - { add_nr_to_hash(ref MySaveDataHash, name_mobile, str_1 + name_mobile + str_2 + CleanUpNumberMobile + str_3, contactData.combinedname); num_export++; } + if (CleanUpNumberMobile != "") + { add_nr_to_hash(ref MySaveDataHash, name_mobile, str_1 + name_mobile + str_2 + CleanUpNumberMobile + str_3, contactData.combinedname); } } // end of foreach loop for the contacts @@ -3327,9 +3837,7 @@ private void save_data_GrandstreamGXP(string filename, System.Collections.Hashta System.IO.File.WriteAllText(filename, resultSB.ToString(), Encoding.GetEncoding("ISO-8859-1")); // tell the user this has been done - string errorwarning = ""; - if (num_export == limit_export) { errorwarning = Environment.NewLine + "Warning: Only " + num_export + " contacts have been exported! The GXP-2000 probably does not support more than 250!"; } - MessageBox.Show(MySaveDataHash.Count + " contacts written to " + filename + " !" + Environment.NewLine + errorwarning); + MessageBox.Show(MySaveDataHash.Count + " contacts written to " + filename + " !"); } @@ -3404,7 +3912,6 @@ private void myConfig_Load() if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "cfg_hideemptycols") { cfg_hideemptycols = Convert.ToBoolean(ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "cfg_adjustablecols") { cfg_adjustablecols = Convert.ToBoolean(ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "cfg_prefixNONFB") { cfg_prefixNONFB = Convert.ToBoolean(ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } - if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "cfg_fritzWorkFirst") { cfg_fritzWorkFirst = Convert.ToBoolean(ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "cfg_importOther") { cfg_importOther = Convert.ToBoolean(ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "cfg_DUPren") { cfg_DUPren = Convert.ToBoolean(ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "cfg_checkVersion") { cfg_checkVersion = Convert.ToBoolean(ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } @@ -3413,6 +3920,11 @@ private void myConfig_Load() if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "clean_slash") { clean_slash = Convert.ToBoolean(ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "clean_hyphen") { clean_hyphen = Convert.ToBoolean(ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "clean_xchar") { clean_xchar = Convert.ToBoolean(ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } + if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "clean_space") { clean_space = Convert.ToBoolean(ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } + if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "clean_squarebrackets") { clean_squarebrackets = Convert.ToBoolean(ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } + if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "clean_letters") { clean_letters = Convert.ToBoolean(ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } + if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "clean_addzeroprefix") { clean_addzeroprefix = Convert.ToBoolean(ParseLine.Substring(ParseLine.IndexOf("\t") + 1)); continue; } + if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "combo_namestyle") { combo_namestyle.SelectedItem = ParseLine.Substring(ParseLine.IndexOf("\t") + 1); continue; } if (ParseLine.Substring(0, ParseLine.IndexOf("\t")) == "combo_typeprefer") { combo_typeprefer.SelectedItem = ParseLine.Substring(ParseLine.IndexOf("\t") + 1); continue; } @@ -3436,7 +3948,6 @@ private void myConfig_Save() sb.AppendLine("cfg_hideemptycols" + "\t" + cfg_hideemptycols.ToString()); sb.AppendLine("cfg_adjustablecols" + "\t" + cfg_adjustablecols.ToString()); sb.AppendLine("cfg_prefixNONFB" + "\t" + cfg_prefixNONFB.ToString()); - sb.AppendLine("cfg_fritzWorkFirst" + "\t" + cfg_fritzWorkFirst.ToString()); sb.AppendLine("cfg_importOther" + "\t" + cfg_importOther.ToString()); sb.AppendLine("cfg_DUPren" + "\t" + cfg_DUPren.ToString()); sb.AppendLine("cfg_checkVersion" + "\t" + cfg_checkVersion.ToString()); @@ -3445,6 +3956,10 @@ private void myConfig_Save() sb.AppendLine("clean_slash" + "\t" + clean_slash.ToString()); sb.AppendLine("clean_hyphen" + "\t" + clean_hyphen.ToString()); sb.AppendLine("clean_xchar" + "\t" + clean_xchar.ToString()); + sb.AppendLine("clean_space" + "\t" + clean_space.ToString()); + sb.AppendLine("clean_squarebrackets" + "\t" + clean_squarebrackets.ToString()); + sb.AppendLine("clean_letters" + "\t" + clean_letters.ToString()); + sb.AppendLine("clean_addzeroprefix" + "\t" + clean_addzeroprefix.ToString()); sb.AppendLine("combo_namestyle" + "\t" + combo_namestyle.SelectedItem.ToString()); sb.AppendLine("combo_typeprefer" + "\t" + combo_typeprefer.SelectedItem.ToString()); @@ -3650,6 +4165,9 @@ private string DoWebRequest(string url) + + + } public class GroupDataContact diff --git a/source/ImportGroupsChooser.Designer.cs b/source/ImportGroupsChooser.Designer.cs new file mode 100644 index 0000000..7d9f538 --- /dev/null +++ b/source/ImportGroupsChooser.Designer.cs @@ -0,0 +1,75 @@ +namespace Contact_Conversion_Wizard +{ + partial class ImportGroupsChooser + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.listBox1 = new System.Windows.Forms.ListBox(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.Location = new System.Drawing.Point(12, 57); + this.listBox1.Name = "listBox1"; + this.listBox1.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; + this.listBox1.Size = new System.Drawing.Size(419, 355); + this.listBox1.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 20); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(35, 13); + this.label1.TabIndex = 1; + this.label1.Text = "label1"; + // + // ImportGroupsChooser + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(444, 424); + this.Controls.Add(this.label1); + this.Controls.Add(this.listBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.Name = "ImportGroupsChooser"; + this.Text = "GoogleImportGroupsChooser"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ImportGroupsChooser_FormClosing); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/source/ImportGroupsChooser.cs b/source/ImportGroupsChooser.cs new file mode 100644 index 0000000..721095b --- /dev/null +++ b/source/ImportGroupsChooser.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace Contact_Conversion_Wizard +{ + public partial class ImportGroupsChooser : Form + { + private List intList; + public List resultList; + + + public ImportGroupsChooser(string question, string windowtitle, List myList) + { + InitializeComponent(); + + intList = myList; + + label1.Text = question; + this.Text = windowtitle; + + foreach (string[] x in myList) + { + listBox1.Items.Add(x[0]); + } + + + } + + private void ImportGroupsChooser_FormClosing(object sender, FormClosingEventArgs e) + { + resultList = new List(); + + for (int i = 0; i < listBox1.Items.Count; i++) + { // Determine if the item is selected. + if (listBox1.GetSelected(i) == true) { resultList.Add(this.intList[i]); } + } + + + } + } +} diff --git a/source/LumenWorks/LumenWorks.Framework.IO.dll b/source/LumenWorks/LumenWorks.Framework.IO.dll index 524938f..404fa66 100644 Binary files a/source/LumenWorks/LumenWorks.Framework.IO.dll and b/source/LumenWorks/LumenWorks.Framework.IO.dll differ diff --git a/source/LumenWorks/webpage.txt b/source/LumenWorks/webpage.txt index 559a206..a52fbad 100644 --- a/source/LumenWorks/webpage.txt +++ b/source/LumenWorks/webpage.txt @@ -1,3 +1,3 @@ -Version 3.8 (retrieved 2011-08-13) +Version 3.81 (retrieved 2012-07-30) from: http://www.codeproject.com/KB/database/CsvReader.aspx diff --git a/source/Properties/AssemblyInfo.cs b/source/Properties/AssemblyInfo.cs index b4a362d..3983347 100644 --- a/source/Properties/AssemblyInfo.cs +++ b/source/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("NV-Systems")] [assembly: AssemblyProduct("Contact Conversion Wizard")] -[assembly: AssemblyCopyright("Copyright © NV-Systems 2011")] +[assembly: AssemblyCopyright("Copyright © NV-Systems 2013")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.4.0.5")] -[assembly: AssemblyFileVersion("3.4.0.5")] +[assembly: AssemblyVersion("3.5.0.0")] +[assembly: AssemblyFileVersion("3.5.0.0")] diff --git a/source/SimpleInputDialog.cs b/source/SimpleInputDialog.cs index d410126..d857faf 100644 --- a/source/SimpleInputDialog.cs +++ b/source/SimpleInputDialog.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; @@ -13,14 +12,17 @@ public partial class SimpleInputDialog : Form public string resultstring; bool my_onlynumeric; - public SimpleInputDialog(string question, string windowtitle, bool onlynumeric) + public SimpleInputDialog(string question, string windowtitle, bool onlynumeric, bool hide_password) { InitializeComponent(); label1.Text = question; this.Text = windowtitle; + textBox1.UseSystemPasswordChar = hide_password; my_onlynumeric = onlynumeric; + + textBox1.AcceptsReturn = true; } private void SimpleInputDialog_FormClosing(object sender, FormClosingEventArgs e) @@ -38,17 +40,38 @@ private void SimpleInputDialog_FormClosing(object sender, FormClosingEventArgs e private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { + if (e.KeyChar == (char)Keys.Return) + { + // if enter is pressed and we have valid input in the textbox, quit this form and return result to caller + if (textBox1.Text != "") + { + e.Handled = true; // prevents bling sound + this.Close(); + return; + } + } + if (my_onlynumeric == true) { if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; + return; } } else { e.Handled = false; + return; } + + + + } + + private void button_OK_Click(object sender, EventArgs e) + { + this.Close(); } } }