protected string GetState(List <DnsMapping> tmappings, bool write) { DnsState state = new DnsState(); state.Mappings = new DnsMapping[_mappings.Count]; _mappings.Values.CopyTo(state.Mappings, 0); Array.Sort(state.Mappings, new MappingComparer()); state.TmpMappings = tmappings.ToArray(); if (write) { Utils.WriteConfig(STATEPATH, state); } return(SocialUtils.ObjectToXml <DnsState>(state)); }
protected string Process(Dictionary <string, string> request) { EventHandler process_event = ProcessEvent; string response = String.Empty; if (process_event != null) { try { process_event(request, EventArgs.Empty); response = request["response"]; } catch (Exception e) { response = SocialUtils.ObjectToXml <string>(e.Message); } } if (request.ContainsKey("html")) { response = "<html><head><meta HTTP-EQUIV=\"REFRESH\" " + "content=\"0;url=html\" /></head></html>"; } return(response); }
public string GetState(bool write) { #if SVPN_NUNIT return(String.Empty); #else FileState fstate = new FileState(); SocialState state = new SocialState(); if (_node.LocalUser != null) { state.LocalUser = _node.LocalUser; fstate.Uid = state.LocalUser.Uid; fstate.PCID = state.LocalUser.PCID; } state.Friends = new SocialUser[_node.Friends.Values.Count]; state.Networks = new NetworkState[_networks.Values.Count]; state.Pending = new string[_pending.Count]; fstate.Friends = new FriendState[_node.Friends.Values.Count]; _pending.CopyTo(state.Pending, 0); int i = 0; foreach (KeyValuePair <string, ISocialNetwork> kvp in _networks) { state.Networks[i] = new NetworkState(); state.Networks[i].Name = kvp.Key; state.Networks[i].Message = kvp.Value.Message; i++; } i = 0; foreach (SocialUser user in _node.Friends.Values) { string status; if (_node.IsAllowed(user.Address)) { if (IsOffline(user.Address)) { status = StatusTypes.Offline.ToString(); } else { status = StatusTypes.Online.ToString(); } } else { status = StatusTypes.Blocked.ToString(); } state.Friends[i] = new SocialUser(user.Certificate, user.IP, status); FriendState friend = new FriendState(); friend.Certificate = user.Certificate; friend.IP = user.IP; friend.Status = status; fstate.Friends[i] = friend; i++; } if (write) { Utils.WriteConfig(STATEPATH, fstate); } return(SocialUtils.ObjectToXml <SocialState>(state)); #endif }