private void DoFilterNewsGroups(string filterText) { if (String.Compare(currentNGFilter, filterText, true) != 0) { NntpServerDefinition sd = this.GetSelectedNntpServerDefinition(); IList <string> groups = null; if (listOfGroups.Tag == null) { if (sd != null) { listOfGroups.Tag = groups = application.LoadNntpNewsGroups(this, sd, false); this.PopulateNewsGroups(sd, groups, application.CurrentSubscriptions(sd)); } } else { groups = (IList <string>)listOfGroups.Tag; } if (String.IsNullOrWhiteSpace(filterText)) // reset to view all { this.PopulateNewsGroups(sd, groups, application.CurrentSubscriptions(sd)); } else // do filter { Regex regFilter = new Regex(filterText.Trim(), RegexOptions.IgnoreCase); this.PopulateNewsGroups(sd, groups, application.CurrentSubscriptions(sd), regFilter); } } currentNGFilter = filterText; }
private void PopulateNntpServerDefinition(string nntpServerID) { if (nntpServerID != null && this.nntpServers.Contains(nntpServerID)) { NntpServerDefinition sd = (NntpServerDefinition)this.nntpServers[nntpServerID]; txtNewsAccountName.Text = sd.Name; cboDefaultIdentities.Text = sd.DefaultIdentity; chkConsiderServerOnRefresh.Checked = false; if (sd.PreventDownloadOnRefreshSpecified) { chkConsiderServerOnRefresh.Checked = !sd.PreventDownloadOnRefresh; } txtNewsServerName.Text = sd.Server; string u, p; FeedSource.GetNntpServerCredentials(sd, out u, out p); chkUseAuthentication.Checked = false; txtServerAuthName.Enabled = txtServerAuthPassword.Enabled = false; if (!string.IsNullOrEmpty(u)) { chkUseAuthentication.Checked = true; txtServerAuthName.Enabled = txtServerAuthPassword.Enabled = true; txtServerAuthName.Text = u; txtServerAuthPassword.Text = p; } else { txtServerAuthName.Text = txtServerAuthPassword.Text = String.Empty; } txtServerPort.Text = String.Empty; if (sd.PortSpecified) { txtServerPort.Text = sd.Port.ToString(); } chkUseSSL.Checked = false; if (sd.UseSSLSpecified) { chkUseSSL.Checked = sd.UseSSL; } trackBarServerTimeout.Value = 0; lblCurrentTimout.Text = "0"; if (sd.TimeoutSpecified) { trackBarServerTimeout.Value = sd.Timeout; lblCurrentTimout.Text = sd.Timeout.ToString(); } IList <string> groups = application.LoadNntpNewsGroups(this, sd, false); listOfGroups.Tag = null; this.PopulateNewsGroups(sd, groups, application.CurrentSubscriptions(sd)); } }
private void OnDeleteItemToolActivate(object sender, EventArgs e) { if (currentView == NewsgroupSettingsView.Identity) { if (listAccounts.SelectedItems.Count > 0) { string key = (string)listAccounts.SelectedItems[0].Tag; if (key != null && this.userIdentities.Contains(key)) { UserIdentity ui = (UserIdentity)this.userIdentities[key]; this.userIdentities.Remove(key); // remove from default identities list AND assigned nntp servers: this.cboDefaultIdentities.Items.Remove(ui.Name); foreach (string serverKey in this.nntpServers.Keys) { NntpServerDefinition sd = (NntpServerDefinition)this.nntpServers[serverKey]; if (sd.DefaultIdentity == ui.Name) { sd.DefaultIdentity = String.Empty; } } this.listAccounts.Items.Remove(listAccounts.SelectedItems[0]); } } } else { if (treeServers.SelectedNode != null) { TreeNode n = null; if (treeServers.SelectedNode.Parent != null) { n = treeServers.SelectedNode.Parent; } else { n = treeServers.SelectedNode; } string key = (string)n.Tag; if (key != null && this.nntpServers.Contains(key)) { //NntpServerDefinition sd = (NntpServerDefinition)this.nntpServers[key]; this.nntpServers.Remove(key); this.treeServers.Nodes.Remove(n); } } } }
private void PopulateNewsGroups(NntpServerDefinition sd, IList <string> groups, IList <NewsFeed> currentSubscriptions, Regex filterExpression) { if (groups != null) { ArrayList alvs = new ArrayList(groups.Count); //int imageIndex = 0; foreach (string group in groups) { // String.Empty is the group description //TODO: how we get this nntp group description? //DISCUSS: how is the NewsFeed.link build up? // all NewsFeed objects with f.newsaccount == sd.Name foreach (NewsFeed f in currentSubscriptions) { /* if (f.link.IndexOf(group) >= 0) * imageIndex = 1; subscribed */ } //TODO: add the "Subscribed" icon, if server/group match an item in currentSubscriptions if (filterExpression == null || filterExpression.IsMatch(group)) { alvs.Add(new ListViewItem(new string[] { group, String.Empty })); } } ListViewItem[] lvs = null; if (alvs.Count > 0) { lvs = new ListViewItem[alvs.Count]; alvs.CopyTo(lvs); } lock (this.listOfGroups.Items) { this.listOfGroups.Items.Clear(); if (lvs != null) { this.listOfGroups.Items.AddRange(lvs); } } } else { lock (this.listOfGroups.Items) { this.listOfGroups.Items.Clear(); } } }
private void btnRefreshGroupList_Click(object sender, EventArgs e) { try { using (new Genghis.Windows.Forms.CursorChanger(Cursors.WaitCursor)) { NntpServerDefinition sd = this.GetSelectedNntpServerDefinition(); if (sd != null) { IList <string> groups = application.LoadNntpNewsGroups(this, sd, true); listOfGroups.Tag = null; this.PopulateNewsGroups(sd, groups, application.CurrentSubscriptions(sd)); } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void DoSubscribe() { if (listOfGroups.SelectedItems.Count > 0) { ListViewItem lv = listOfGroups.SelectedItems[0]; NntpServerDefinition sd = GetSelectedNntpServerDefinition(); if (sd != null) { ICoreApplication coreApp = IoC.Resolve <ICoreApplication>(); if (coreApp != null) { if (coreApp.SubscribeToFeed( IdentityNewsServerManager.BuildNntpRequestUri(sd, lv.Text).ToString(), null, lv.Text)) { //TODO set icon } } } } }
private void AddNewsServer(NntpServerDefinition sd) { if (sd == null) { throw new ArgumentNullException("sd"); } if (string.IsNullOrEmpty(sd.Name)) { sd.Name = "New"; // SR.NewNntpServerAccountNameTemplate"]; } if (this.nntpServers.Contains(sd.Name)) { do { unnamedNntpServerCounter++; } while(this.nntpServers.Contains(sd.Name + " #" + unnamedNntpServerCounter)); sd.Name += " #" + unnamedNntpServerCounter; } this.nntpServers.Add(sd.Name, sd); TreeNode[] childs = new TreeNode[3]; childs[0] = new TreeNode(SR.NntpServerConfig_GeneralSettingsNodeCaption, 2, 2); childs[1] = new TreeNode(SR.NntpServerConfig_ServerSettingsNodeCaption, 3, 3); childs[2] = new TreeNode(SR.NntpServerConfig_AdvancedSettingsNodeCaption, 4, 4); childs[0].Tag = NewsgroupSettingsView.NewsServerGeneral; childs[1].Tag = NewsgroupSettingsView.NewsServerSettings; childs[2].Tag = NewsgroupSettingsView.NewsServerAdvanced; TreeNode newItem = new TreeNode(sd.Name, 1, 1, childs); newItem.Tag = sd.Name; treeServers.Nodes.Add(newItem); treeServers.SelectedNode = childs[0]; // cause event fired }
private void OnWidgetValidated(object sender, System.EventArgs e) { // general widget validated. UserIdentity selectedUser = this.GetSelectedUserIdentity(); NntpServerDefinition selectedServer = this.GetSelectedNntpServerDefinition(); if (sender == this.txtIdentityName) { if (selectedUser != null) { selectedUser.Name = this.txtIdentityName.Text; } } if (sender == this.txtUserName) { if (selectedUser != null) { selectedUser.RealName = this.txtUserName.Text; } } if (sender == this.txtUserOrg) { if (selectedUser != null) { selectedUser.Organization = this.txtUserOrg.Text; } } if (sender == this.txtUserMail) { if (selectedUser != null) { selectedUser.MailAddress = this.txtUserMail.Text; } } if (sender == this.txtUserMailResponse) { if (selectedUser != null) { selectedUser.ResponseAddress = this.txtUserMailResponse.Text; } } if (sender == this.txtRefererUrl) { if (selectedUser != null) { selectedUser.ReferrerUrl = this.txtRefererUrl.Text; } } if (sender == this.txtSignature) { if (selectedUser != null) { selectedUser.Signature = this.txtSignature.Text; } } // Nntp server def. takeover if (sender == this.txtNewsAccountName) { if (selectedServer != null) { selectedServer.Name = this.txtNewsAccountName.Text; } } if (sender == this.cboDefaultIdentities) { if (selectedServer != null) { selectedServer.DefaultIdentity = this.cboDefaultIdentities.Text; } } if (sender == this.chkConsiderServerOnRefresh) { if (selectedServer != null) { selectedServer.PreventDownloadOnRefreshSpecified = (!this.chkConsiderServerOnRefresh.Checked); selectedServer.PreventDownloadOnRefresh = !this.chkConsiderServerOnRefresh.Checked; } } if (sender == this.txtNewsServerName) { if (selectedServer != null) { selectedServer.Server = this.txtNewsServerName.Text; } } if (sender == this.txtServerAuthName) { if (selectedServer != null) { selectedServer.AuthUser = this.txtServerAuthName.Text; } } if (sender == this.txtServerAuthPassword) { if (selectedServer != null) { FeedSource.SetNntpServerCredentials( selectedServer, this.txtServerAuthName.Text, txtServerAuthPassword.Text); } } if (sender == this.txtServerPort) { if (selectedServer != null) { int port = Int32.Parse(this.txtServerPort.Text); if (port > 0 && port != NntpWebRequest.NntpDefaultServerPort) { selectedServer.Port = port; selectedServer.PortSpecified = true; } else { selectedServer.PortSpecified = false; } } } if (sender == this.chkUseSSL) { if (selectedServer != null) { selectedServer.UseSSLSpecified = (this.chkUseSSL.Checked); selectedServer.UseSSL = this.chkUseSSL.Checked; } } if (sender == this.trackBarServerTimeout) { if (selectedServer != null) { selectedServer.TimeoutSpecified = false; if (trackBarServerTimeout.Value > 0) { selectedServer.TimeoutSpecified = true; selectedServer.Timeout = trackBarServerTimeout.Value; } } } this.btnApply.Enabled = true; }
private void PopulateNewsGroups(NntpServerDefinition sd, IList <string> groups, IList <NewsFeed> currentSubscriptions) { this.PopulateNewsGroups(sd, groups, currentSubscriptions, null); }