--- /dev/null
+using System;
+
+using util;
+
+namespace mCloudAwk
+{
+ public class MCloudMgr : IMCloudAwk, IDisposable
+ {
+ public TConnection[] GetConnections()
+ {
+ var Connections = util.Config.GetList ("General", "Connections");
+ if (Connections == null)
+ return new TConnection[0];
+ TConnection[] TConns = new TConnection[Connections.Count];
+ int i = 0;
+ foreach (var C in Connections) {
+ TConnection TC = new TConnection ();
+ TC.Name = C;
+ TC.User = util.Config.RequireConfig (TC.Name, "User");
+ TC.Server = util.Config.RequireConfig (TC.Name, "Server");
+ TC.Password = util.Config.RequireConfig (TC.Name, "Password");
+ TConns [i] = TC;
+ i++;
+ }
+ return TConns;
+ }
+
+ public void AddConnection(TConnection C) {
+ var Connections = util.Config.GetList ("General", "Connections");
+ if (Connections == null) {
+ Connections = new System.Collections.Generic.SortedSet<string> { C.Name };
+ } else {
+ Connections.Add (C.Name);
+ }
+ Config.Set ("General", "Connections", Connections);
+ Config.Set (C.Name, "User", C.User);
+ Config.Set (C.Name, "Server", C.Server);
+ Config.Set (C.Name, "Password", C.Password);
+ }
+
+ public void DeleteConnection(string name) {
+ var Connections = Config.GetList ("General", "Connections");
+ Connections.Remove (name);
+ Config.Set("General", "Connections", Connections);
+ Config.Remove(name);
+ }
+
+ // TestConnection results
+ public const int SSH_NO_PW = 0; // connection without password possible
+ public const int SSH_WITH_PW = 1; // connection only possible with password
+ public const int SSH_NOK = 10; // so ssh connection possible
+ public int TestConnection(string name){return 5;}
+
+ public MCloudMgr(){
+ int r = util.Config.Load (System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal)
+ +"/.mCloud.Config");
+ if (r == util.Config.LOAD_OK || r == util.Config.LOAD_NO_INPUT_FILE) {
+ // everything fine
+ } else {
+ throw new ApplicationException ("Config load failed");
+ }
+ }
+
+ public void Dispose() {
+ util.Config.Write ();
+ }
+ }
+}
+