void onServerClipboard() { string newclipboard = null; try { if (xsSetClipboard.Exists()) { newclipboard = xsSetClipboard.value; Debug.Print("get new clipboard " + newclipboard); xsSetClipboard.Remove(); } else { return; } } catch { return; } if (newclipboard == null) { currentclipboard = totalclipboard; setClientClipboard(totalclipboard); totalclipboard = ""; } else { totalclipboard += newclipboard; } }
protected override void Finish() { registered = false; pvmajor.Remove(); pvminor.Remove(); pvmicro.Remove(); pvbuild.Remove(); WmiBase.Singleton.Kick(); base.Finish(); }
override protected void onFeature() { if (controlKey.Exists() && !state.Exists()) { try { if (error.Exists()) { error.Remove(); } if (!domainName.Exists()) { error.value = "domainname must be specified"; throw new Exception("domainname must be specified"); } if (!userName.Exists()) { error.value = "username must be specified"; throw new Exception("username must be specified"); } if (!password.Exists()) { error.value = "password must be specified"; throw new Exception("password must be specified"); } if (controlKey.value.Equals("joindomain")) { JoinDomain(); } else if (controlKey.value.Equals("unjoindomain")) { UnjoinDomain(); } // If completed, remove the arguments, to avoid // them hanging around in xenstore. domainName.Remove(); userName.Remove(); password.Remove(); } catch (Exception e) { if (!error.Exists()) { error.value = e.ToString(); } state.value = "Failed"; } finally { // We always want to remove the controlKey, so that // it can be set again controlKey.Remove(); } } }
override protected void onFeature() { Debug.Print("Snapshot on feature"); if ((!controlKey.Exists()) || (controlKey.value != "create-snapshot")) { return; } Debug.Print("Manage keys"); controlKey.Remove(); actionKey.Remove(); Debug.Print("Call background thread"); startSnapshotThread(snapshotThreadHandler); }
void addLicenseInfoToStore() { try { if (oslicense.Exists()) { oslicense.Remove(); } switch (Win32Impl.IsGenuineWindows()) { case Win32Impl.SL_GENUINE_STATE.SL_GEN_STATE_INVALID_LICENSE: oslicense.value = licenseinvalid; break; case Win32Impl.SL_GENUINE_STATE.SL_GEN_STATE_IS_GENUINE: oslicense.value = licensegenuine; break; case Win32Impl.SL_GENUINE_STATE.SL_GEN_STATE_TAMPERED: oslicense.value = licensetampered; break; default: break; } } catch { //Do nothing if IsGenuineWindows doesn't exist }; try { if (osvirtualxp.Exists()) { osvirtualxp.Remove(); } if (Win32Impl.GetWindowsInformation("VirtualXP-licensing-Enabled") != 0) { osvirtualxp.value = "1"; } else { osvirtualxp.value = "0"; } } catch (Exception e) { WmiBase.Singleton.DebugMsg("GetWindowsInformation failed: \n" + e.ToString()); } }
override protected void onFeature() { if (controlKey.Exists() && !state.Exists()) { try { if (error.Exists()) { error.Remove(); } if (warn.Exists()) { warn.Remove(); } if (state.Exists()) { error.value = "Setting name already in progress"; state.value = "Failed"; return; } if (controlKey.value.Equals("set")) { SetComputerName(); } else { error.value = "Unknown action : " + controlKey.value; state.value = "Failed"; } } catch (Exception e) { if (!error.Exists()) { error.value = e.ToString(); } state.value = "Failed"; } finally { // We always want to remove the controlKey, so that // it can be set again controlKey.Remove(); } } }
protected virtual void Finish() { if (advert != null) { if (advert != null) { try { advert.Remove(); } catch { }; } features.Remove(this); advert = null; } if (listener != null) { listener.Dispose(); listener = null; } }
void SetComputerName() { wmisession.Log("Set Computer Name Requested"); state.value = "InProgress"; String defaultname; bool res; try { defaultname = name.value; name.Remove(); } catch { try { wmisession.Log("Setting computer name to default"); AXenStoreItem name = wmisession.GetXenStoreItem("name"); defaultname = name.value; } catch (Exception e) { wmisession.Log("Unable to read default name for domain from xenstore: " + e.ToString()); error.value = "Can't read default computer name"; state.value = "Failed"; return; } } if (defaultname.Equals("")) { wmisession.Log("Can't set to empty computer name"); error.value = "Computer name empty"; state.value = "Failed"; return; } if (defaultname.Length > Win32Impl.MAX_COMPUTERNAME_LENGTH) { warn.value = "Computer name exceeds MAX_COMPUTERNAME_LENGTH. The NetBIOS name will be truncated"; } try { wmisession.Log("Setting computer name to " + defaultname); Win32Impl.SetLastError(0); res = Win32Impl.SetComputerNameEx(Win32Impl.COMPUTER_NAME_FORMAT.ComputerNamePhysicalDnsHostname, defaultname); if (!res) { wmisession.Log("Setting computer name failed " + Marshal.GetLastWin32Error().ToString()); error.value = "Setting name failed (error code " + Marshal.GetLastWin32Error().ToString() + ")"; state.value = "Failed"; return; } wmisession.Log("Setting computer name succceded"); } catch (Exception e) { wmisession.Log("Exception setting computer name : " + e.ToString()); error.value = "Exception calling set computer name"; state.value = "Failed"; return; } try { wmisession.Log("Target hostname " + defaultname); wmisession.Log("Current hostname" + Win32Impl.GetComputerDnsHostname()); if (defaultname.Equals(Win32Impl.GetComputerDnsHostname())) { wmisession.Log("No need to reboot to change computer name, already " + defaultname); state.value = "NoChange"; return; } } catch { } state.value = "SucceededNeedsReboot"; }
protected override void onFeature() { if (controlKey.Exists()) { try { foreach (string nic in staticIpSetting.children) { mac = wmisession.GetXenStoreItem(nic + "/static-ip-setting/mac"); ipenabled = wmisession.GetXenStoreItem(nic + "/static-ip-setting/enabled"); ipv6enabled = wmisession.GetXenStoreItem(nic + "/static-ip-setting/enabled6"); errorCode = wmisession.GetXenStoreItem(nic + "/static-ip-setting/error-code"); errorMsg = wmisession.GetXenStoreItem(nic + "/static-ip-setting/error-msg"); if (ipenabled.Exists() && ipenabled.value.Length != 0) { if (int.Parse(ipenabled.value) == 1) // assign static ip setting { address = wmisession.GetXenStoreItem(nic + "/static-ip-setting/address"); gateway = wmisession.GetXenStoreItem(nic + "/static-ip-setting/gateway"); SetStaticIpv4Setting(); wmisession.Log("Static ip setting is assigned."); } else // remove static ip setting { UnsetStaticIpv4Setting(); wmisession.Log("Static ip setting is unassigned."); } } if (ipenabled.Exists()) { ipenabled.Remove(); } if (ipv6enabled.Exists() && ipv6enabled.value.Length != 0) { if (int.Parse(ipv6enabled.value) == 1) // assign static ipv6 setting { address6 = wmisession.GetXenStoreItem(nic + "/static-ip-setting/address6"); gateway6 = wmisession.GetXenStoreItem(nic + "/static-ip-setting/gateway6"); SetStaticIpv6Setting(); wmisession.Log("Static ipv6 setting is assigned."); } else // remove static ipv6 setting { UnsetStaticIpv6Setting(); wmisession.Log("Static ipv6 setting is unassigned."); } } if (ipv6enabled.Exists()) { ipv6enabled.Remove(); } } } catch { }; // Ignore failure, if node does not exist } }