public KwsSetUserProperty(WorkspaceManager wm, Workspace kws, UInt32 userId, String newPwd) : base(wm) { m_kws = kws; m_targetUserId = userId; m_stringParam = newPwd; }
public KcdQuery(AnpMsg cmd, KcdQueryDelegate callback, WmKcd kcd, Workspace kws) { Debug.Assert(cmd.ID != 0); Cmd = cmd; Callback = callback; Kcd = kcd; Kws = kws; }
public OutlookEventProxy(WorkspaceManager wm, Workspace kws) { m_Wm = wm; m_Kws = kws; Debug.Assert(m_Kws.EventProxy == null); m_Kws.EventProxy = this; m_Kws.OnEventReceived += EventReceivedHandler; }
private void SendUserUpdateEvent(Workspace kws, AnpMsg msg) { AnpMsg evt = m_Wm.OutlookBroker.MakeEvent(OAnpType.OANP_EVT_USER_UPDATE); evt.AddUInt64(kws.InternalID); evt.AddUInt64(msg.Elements[1].UInt64); evt.AddUInt32((UInt32)kws.CoreData.UserInfo.UserTree.Count); foreach (KwsUser user in kws.CoreData.UserInfo.UserTree.Values) { evt.AddUInt32(user.UserID); evt.AddString(user.AdminName); evt.AddString(user.UserName); evt.AddString(user.EmailAddress); evt.AddUInt32(user.Power); evt.AddString(user.OrgName); } m_Wm.OutlookBroker.SendEvent(evt); }
public OutlookInviteOp(WorkspaceManager wm, Workspace kws, WmOutlookRequest request) : base(wm, kws) { RegisterOutlookRequest(request); }
public BaseInviteOp(WorkspaceManager wm, Workspace kws) : base(wm) { m_kws = kws; m_ih = new KwsInviteOpHelper(this, m_kws.CoreData.Credentials); }
/// <summary> /// Cancel the KAS queries related to the workspace specified. If /// logoutFlag is true, only the queries that have the /// ClearOnLogoutFlag set are removed. /// </summary> public void CancelKwsKasQuery(Workspace kws, bool logoutFlag) { List<WmKasQuery> list = new List<WmKasQuery>(); foreach (WmKasQuery query in QueryMap.Values) if (query.Kws == kws && (!logoutFlag || query.ClearOnLogoutFlag)) list.Add(query); foreach (WmKasQuery query in list) query.Cancel(); }
/// <summary> /// Updates the form's UI (Home tab info, title bar, workspace users). /// </summary> public void UpdateUI(Workspace kws) { ToolStripLabel statusKwsName = AppStatusStrip.Items[2] as ToolStripLabel; Debug.Assert(statusKwsName != null); UpdateDeleteItemToolbarButton(); // Set the title and status bar. if (kws == null) { HideAdvancedView(); this.Text = Base.GetKwmString(); statusKwsName.Visible = false; kwsHeader.Visible = false; createKwsHeader.Visible = true; } else { createKwsHeader.Visible = false; kwsHeader.Visible = true; kwsHeader.UpdateUI(kws); if (kwsHeader.HasError || Misc.ApplicationSettings.ShowMainFormAdvancedView) ShowAdvancedView(); else HideAdvancedView(); this.Text = Base.GetKwmString() + " - " + kws.GetKwsName(); statusKwsName.Visible = true; statusKwsName.Text = kws.GetKwsName(); lnkShowProperties.Enabled = !kws.IsPublicKws(); } // Update the invitation controls status. UpdateInviteStatus(kws); // Set the user list. UpdateKwsUserList(kws); }
/// <summary> /// Cancel the KCD queries related to the workspace specified. /// </summary> public void CancelKwsKcdQuery(Workspace kws) { List<KcdQuery> list = new List<KcdQuery>(); foreach (KcdQuery query in QueryMap.Values) if (query.Kws == kws) list.Add(query); foreach (KcdQuery query in list) query.Terminate(); }
/// <summary> /// Helper method that wraps a Kws export and its parent folder path. /// </summary> private void ExportKws(Workspace kws, XmlDocument doc, XmlElement parent) { // Bail out if we cannot export the workspace. if (!kws.Sm.CanExport()) return; // Get the parent folder of this workspace. KwsBrowserNode node = UiBroker.Browser.GetKwsNodeByKws(kws); Debug.Assert(node != null); ExportedKws expKws = new ExportedKws(kws, node.Parent.FullPath); expKws.ToXml(doc, parent); }
/// <summary> /// Update the invitation UI (button, textbox and linklabel) so that /// the controls are enabled at the right moment. /// </summary> private void UpdateInviteStatus(Workspace kws) { if (kws == null) { btnInvite.Enabled = false; btnCustomInvite.Enabled = false; return; } bool enable = (kws.LoginStatus == KwsLoginStatus.LoggedIn && kws.IsOnlineCapable() && !kws.IsPublicKws()); btnInvite.Enabled = enable; btnCustomInvite.Enabled = enable; }
/// <summary> /// Remove the workspace object from the workspace manager. /// </summary> public void RemoveWorkspaceObject(Workspace kws) { try { WmKas kas = kws.Kas; Debug.Assert(kws.RefCount == 0); Debug.Assert(KwsTree.ContainsKey(kws.InternalID)); Debug.Assert(kas.KwsTree.ContainsKey(kws.InternalID)); Debug.Assert(!kas.KwsConnectTree.ContainsKey(kws.InternalID)); // Cancel the KAS queries related to the workspace. kas.CancelKwsKasQuery(kws, false); // Unregister the workspace from the KAS object. Get rid of the // KAS object if required. kas.KwsTree.Remove(kws.InternalID); RemoveKasIfNoRef(kas); // Unregister the workspace from the manager. KwsTree.Remove(kws.InternalID); if (KwsRemoveTree.ContainsKey(kws.InternalID)) KwsRemoveTree.Remove(kws.InternalID); AdjustPublicKwsID(); // Remove the workspace from its containing folder. UiBroker.RequestBrowserUiUpdate(true); if (UiBroker.Browser.SelectedKws == kws) UiBroker.RequestSelectOtherKws(kws); UiBroker.Browser.RemoveKws(kws); SetDirty(); } catch (Exception ex) { Base.HandleException(ex, true); } }
/// <summary> /// Insert the workspace in the database. /// </summary> private void AddKwsToDb(Workspace kws) { LocalDbBroker.AddKwsToKwsList(kws.InternalID, kws.CoreData.Credentials.KwsName); }
/// <summary> /// "Import" a workspace that already exists in the KWM. /// </summary> public void ImportExistingKws(Workspace kws, KwsCredentials creds, bool singleFlag) { KwsTask task = kws.Sm.GetCurrentTask(); Logging.Log("Import of existing workspace " + kws.InternalID + " with task " + task + " requested."); // Do not do anything if the workspace is being spawned, removed or // is already working online. if (task == KwsTask.Spawn || task == KwsTask.Remove || task == KwsTask.WorkOnline) { Logging.Log("Skipping import."); return; } // Update the credentials unless they were already accepted. if (kws.KasLoginHandler.LoginResult != KwsLoginResult.Accepted) { Logging.Log("Updating workspace credentials."); creds.PublicFlag = kws.CoreData.Credentials.PublicFlag; kws.CoreData.Credentials = creds; } // Make the workspace work online. if (task == KwsTask.WorkOffline || task == KwsTask.Stop) { KwsLoginType loginType = singleFlag ? KwsLoginType.All : KwsLoginType.NoPwdPrompt; Logging.Log("Switching to WorkOnline task with login type " + loginType + "."); kws.Sm.SetLoginType(loginType); kws.Sm.RequestTaskSwitch(KwsTask.WorkOnline); } }
/// <summary> /// Create a new workspace object having the credentials specified and /// insert it in the workspace manager, with the current task Stop and /// under the folder specified. Set selectFlag to true if you want the /// workspace to be selected once created. /// </summary> public Workspace CreateWorkspaceObject(KwsCredentials creds, KwsBrowserFolderNode folder, bool firstFlag) { try { // Clear the public flag if we already have a public workspace. if (PublicKwsID != 0) creds.PublicFlag = false; // Get the KAS object. WmKas kas = GetOrCreateKas(creds.KasID); // Create the workspace object, if possible. Workspace kws = new Workspace(this, kas, NextKwsInternalId++, creds); // Register the workspace in the WM and the KAS. KwsTree[kws.InternalID] = kws; kas.KwsTree[kws.InternalID] = kws; AdjustPublicKwsID(); // Insert the workspace in the folder specified. UiBroker.Browser.AddKws(kws, folder, firstFlag); UiBroker.RequestBrowserUiUpdate(true); // Insert the workspace in the database. AddKwsToDb(kws); SetDirty(); return kws; } catch (Exception ex) { Base.HandleException(ex, true); return null; } }
public WmKasQuery(AnpMsg cmd, Object[] metaData, KasQueryDelegate callback, WmKas kas, Workspace kws, KwsApp app, bool clearOnLogoutFlag) : base(cmd, metaData, callback) { Kas = kas; Kws = kws; App = app; ClearOnLogoutFlag = clearOnLogoutFlag; }
public KwmInviteOp(WorkspaceManager wm, Workspace kws, String invitees, bool skipFirstPageFlag) : base(wm, kws) { Invitees = invitees; SkipFirstPage = skipFirstPageFlag; }
/// <summary> /// Relink a workspace to the workspace manager after it has been /// deserialized. /// </summary> private void RelinkWorkspaceObject(Workspace kws, KwsBrowserFolderNode folder, bool notifyFlag, bool notInDbFlag) { Debug.Assert(kws != null); // Call Initialize() to restore the link to us. kws.Initialize(this); // Insert the workspace in the database. if (notInDbFlag) AddKwsToDb(kws); // Add the workspace to the workspace tree. KwsTree[kws.InternalID] = kws; // The workspace has a serialized KAS, but it is not the same // object as the one serialized in the WM. We need to correct // that situation. WmKas kas = GetOrCreateKas(kws.Kas.KasID); kws.Kas = kas; kas.KwsTree.Add(kws.InternalID, kws); // Make sure our workspace ID generator is in a sane state. NextKwsInternalId = Math.Max(NextKwsInternalId, kws.InternalID + 1); // Add the workspace to the browser. UiBroker.Browser.AddKws(kws, folder, false); // Set the node's Notify flag. Checking the return value is unnecessary. if (notifyFlag) UiBroker.MarkNodeNotifyFlag(kws); }
/// <summary> /// Set the enabled status of the given item. If the item is disabled, a /// tooltip string is set to explain why the command is unavailable. /// </summary> private void SetKwsToolsStripItemStatus(ToolStripItem item, KwsAction action, Workspace kws) { Debug.Assert(item != null && kws != null); String denyReason = ""; item.Enabled = true; bool can = m_uiBroker.CanPerformKwsAction(action, kws, ref denyReason); if (can) { item.ForeColor = Color.Black; } else { item.ForeColor = Color.Gray; } item.Tag = can; item.ToolTipText = denyReason; }
/// <summary> /// Handle a workspace that want to be connected. /// </summary> public static void HandleKwsToConnect(Workspace kws) { if (kws.InKcdConnectTree()) return; // Add the workspace to the KCD connect tree. kws.AddToKcdConnectTree(); // Run our state machine if this is the first connection request. if (kws.Kcd.KwsConnectTree.Count == 1) RequestRun("KCD connection request"); }
/// <summary> /// Update the workspace user list with the information from the /// workspace specified, if any. /// </summary> private void UpdateKwsUserList(Workspace kws) { lstUsers.BeginUpdate(); lstUsers.Items.Clear(); lstUsers.Enabled = (kws != null); if (kws != null) { // We want to display the user display name preferably. // If a dupe exists, show name and email address, and if no name // is present, just show the email address. foreach (KwsUser user in kws.CoreData.UserInfo.UserTree.Values) { // Ignore banned users. if (user.BanFlag) continue; String userName = user.UiSimpleName; UInt32 dupeID = IsNamePresent(userName); if (dupeID != 0) { // If this username already exists in the UI, use the FullName instead. userName = user.UiFullName; // Go back to the initial dupe and change its display name to the FullName. lstUsers.Items[dupeID.ToString()].Text = kws.CoreData.UserInfo.UserTree[dupeID].UiFullName; } ListViewItem item = new ListViewItem(); item.Name = user.UserID.ToString(); item.Text = userName; item.ToolTipText = user.UiTooltipText; // Mark ourself in a different way. if (user.UserID == kws.CoreData.Credentials.UserID) { item.Font = new Font(item.Font, FontStyle.Bold); } lstUsers.Items.Add(item); } // Sort the list in alphabetical order. lstUsers.Sorting = SortOrder.Ascending; lstUsers.Sort(); // Put the logged on user on top of the list. lstUsers.Sorting = SortOrder.None; ListViewItem i = lstUsers.Items[kws.CoreData.Credentials.UserID.ToString()]; if (i != null) { i.Remove(); lstUsers.Items.Insert(0, i); } UpdateKwsUserSelection(); // Display a link inviting users to add more people to // empty non-public workspaces. if (lstUsers.Items.Count <= 1 && !m_uiBroker.Browser.SelectedKws.IsPublicKws()) { lblLinkInviteUsers.Visible = true; } else { lblLinkInviteUsers.Visible = false; } } lstUsers.EndUpdate(); }
/// <summary> /// Create a new workspace having the credentials specified and insert /// it in the workspace manager, with the current task Stop. /// </summary> public static Workspace CreateWorkspace(KwsCredentials creds) { try { // Clear the public flag if we already have a public workspace. if (Cd.PublicKwsID != 0) creds.PublicFlag = false; // Get a new internal ID. UInt64 internalID = Cd.NextKwsInternalID++; // Register the worskpace in the workspace manager. KwsCoreData kwsCd = new KwsCoreData(); kwsCd.Credentials = creds; Workspace kws = new Workspace(); kws.Relink(internalID, kwsCd); AdjustPublicKwsID(); // Insert the workspace in the workpace list in the database. LocalDbBroker.AddKwsToKwsList(kws.InternalID, kws.Cd.Credentials.KwsName); // The WM state has changed. Wm.OnStateChange(WmStateChange.Permanent); return kws; } catch (Exception ex) { KBase.HandleException(ex, true); return null; } }
public void Relink(Workspace kws) { m_kws = kws; m_cd = kws.Cd; m_ks = m_cd.KcdState; }
/// <summary> /// Remove the workspace object from the workspace manager. Used by the /// WM state machine. /// </summary> public static void RemoveWorkspace(Workspace kws) { try { WmKcd kcd = kws.Kcd; // Make sure the state is valid. Debug.Assert(KwsTree.ContainsKey(kws.InternalID)); if (kcd != null) { Debug.Assert(kcd.KwsTree.ContainsKey(kws.InternalID)); Debug.Assert(!kcd.KwsConnectTree.ContainsKey(kws.InternalID)); } // Unregister the workspace from the workspace manager. KwsTree.Remove(kws.InternalID); if (KwsRemoveTree.ContainsKey(kws.InternalID)) KwsRemoveTree.Remove(kws.InternalID); if (kcd != null) { kcd.CancelKwsKcdQuery(kws); kcd.KwsTree.Remove(kws.InternalID); RemoveKcdIfNoRef(kcd); } AdjustPublicKwsID(); // Delete the workspace data. kws.PrepareToRemove(); foreach (KwsApp app in kws.AppTree.Values) app.PrepareToRemove(); // The WM state has changed. Wm.OnStateChange(WmStateChange.Permanent); } catch (Exception ex) { KBase.HandleException(ex, true); } }
/// <summary> /// Handle a workspace that want to be disconnected. /// </summary> public static void HandleKwsToDisconnect(Workspace kws) { if (!kws.InKcdConnectTree()) return; // Remove the workspace from the KCD connection tree. kws.RemoveFromKcdConnectTree(); // Disconnect the KCD if no workspace want to be connected. if (kws.Kcd.KwsConnectTree.Count == 0) DisconnectKcd(kws.Kcd, null); }
/// <summary> /// Set the reference to the WM and workspace. /// </summary> public void SetRef(WorkspaceManager wm, Workspace kws) { m_wm = wm; m_kws = kws; }
public static void Relink(WmDeserializer ds) { Cd = ds.WmCd; WmSm.Relink(); KcdBroker.OnEvent += WmSm.HandleKcdBrokerNotification; KmodBroker.OnThreadCollected += WmSm.OnThreadCollected; EAnpBroker.OnClose += WmSm.OnThreadCollected; EAnpBroker.OnChannelOpen += WmEAnp.HandleChannelOpen; foreach (UInt64 internalID in ds.KwsCdList.Keys) { Workspace kws = new Workspace(); KwsCoreData kwsCd = ds.KwsCdList[internalID]; kws.Relink(internalID, kwsCd); } AdjustPublicKwsID(); }
/// <summary> /// Process one workspace to remove. /// </summary> private static void ProcessOneKwsToRemove(Workspace kws) { // We can remove the workspace now. if (kws.Sm.ReadyToRemove()) { // Remove the workspace from the manager. Wm.RemoveWorkspace(kws); // Request a run of the state machine in case we want to stop. RequestRun("removed " + KwmStrings.Kws); } }
public KwsKasEventHandler(Workspace kws) { m_kws = kws; }
public ExportedKws(Workspace kws, String folderPath) : this(new KwsCredentials(kws.CoreData.Credentials), folderPath) { }