public bool Start(PkOptions options, Dictionary <string, PkKite> kites) { int numKites = 4 * (1 + kites.Count); // 4 possible protocols int maxConns = 25; int flags = PkLib.PK_WITH_DEFAULTS; int verbosity = options.Debug ? 2 : 0; // FIXME: if (no network connection) // { // // Report error? // return false; // } bool ok = true; try { if (!this.pk.init_pagekitenet(APPID, numKites, maxConns, flags, verbosity)) { PkLogging.Logger(PkLogging.Level.Error, "Initializing LibPageKite failed, aborting"); return(false); } } catch (DllNotFoundException e) { PkLogging.Logger(PkLogging.Level.Error, "Could not locate " + PkLib.DLL); PkLogging.Logger(PkLogging.Level.Error, "Message: " + e.Message); ok = false; } if (ok) { ok = this.StartLogListenerThread(); if (!ok) { this.Stop(false); } } foreach (PkKite kite in kites.Values) { if (ok && kite.Fly) { if (!this.AddKite(kite)) { PkLogging.Logger(PkLogging.Level.Error, "Adding kites failed, aborting"); this.Stop(false); ok = false; } } } if (ok) { int status = this.pk.start(); if (0 > status) { PkLogging.Logger(PkLogging.Level.Error, "Unable to start LibPageKite, aborting"); this.Stop(false); ok = false; } } return(ok); }
public void SetOptions(PkOptions options) { this.pagekiteNetCheckBox.Checked = options.UsePageKiteNet; this.debugCheckBox.Checked = options.Debug; this.rememberMeCheckBox.Checked = options.RememberMe; }
public bool Start(PkOptions options, Dictionary<string, PkKite> kites) { int numKites = 4 * (1 + kites.Count); // 4 possible protocols int maxConns = 25; int flags = PkLib.PK_WITH_DEFAULTS; int verbosity = options.Debug ? 2 : 0; // FIXME: if (no network connection) // { // // Report error? // return false; // } bool ok = true; try { if (!this.pk.init_pagekitenet(APPID, numKites, maxConns, flags, verbosity)) { PkLogging.Logger(PkLogging.Level.Error, "Initializing LibPageKite failed, aborting"); return false; } } catch (DllNotFoundException e) { PkLogging.Logger(PkLogging.Level.Error, "Could not locate " + PkLib.DLL); PkLogging.Logger(PkLogging.Level.Error, "Message: " + e.Message); ok = false; } if (ok) { ok = this.StartLogListenerThread(); if(!ok) { this.Stop(false); } } foreach (PkKite kite in kites.Values) { if (ok && kite.Fly) { if (!this.AddKite(kite)) { PkLogging.Logger(PkLogging.Level.Error, "Adding kites failed, aborting"); this.Stop(false); ok = false; } } } if (ok) { int status = this.pk.start(); if (0 > status) { PkLogging.Logger(PkLogging.Level.Error, "Unable to start LibPageKite, aborting"); this.Stop(false); ok = false; } } return ok; }