public PicasaPicture(GoogleConnection conn, string aid, string pid) { if (conn == null) { throw new ArgumentNullException("conn"); } if (conn.User == null) { throw new ArgumentException("Need authentication before being used.", "conn"); } this.conn = conn; if (aid == null || aid == String.Empty) { throw new ArgumentNullException("aid"); } this.album = new PicasaAlbum(conn, aid); if (pid == null || pid == String.Empty) { throw new ArgumentNullException("pid"); } string received = conn.DownloadString(GDataApi.GetPictureEntry(conn.User, aid, pid)); XmlDocument doc = new XmlDocument(); doc.LoadXml(received); XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); XmlUtil.AddDefaultNamespaces(nsmgr); XmlNode entry = doc.SelectSingleNode("atom:entry", nsmgr); ParsePicture(entry, nsmgr); }
public PicasaWeb(GoogleConnection conn, string username) { if (conn == null) { throw new ArgumentNullException("conn"); } if (conn.User == null && username == null) { throw new ArgumentException("The connection should be authenticated OR you should call this constructor with a non-null username argument"); } this.conn = conn; this.user = username ?? conn.User; string received = conn.DownloadString(GDataApi.GetGalleryEntry(user)); XmlDocument doc = new XmlDocument(); doc.LoadXml(received); XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); XmlUtil.AddDefaultNamespaces(nsmgr); XmlNode entry = doc.SelectSingleNode("atom:entry", nsmgr); ParseGallery(entry, nsmgr); }
public PicasaAlbum(GoogleConnection conn, string user, string aid, string authkey) : this(conn) { if (user == null || user == String.Empty) throw new ArgumentNullException ("user"); if (aid == null || aid == String.Empty) throw new ArgumentNullException ("aid"); this.user = user; this.id = aid; this.authkey = authkey; string download_link = GDataApi.GetAlbumEntryById (user, id); if (authkey != null && authkey != "") download_link += "&authkey=" + authkey; string received = conn.DownloadString (download_link); XmlDocument doc = new XmlDocument (); doc.LoadXml (received); XmlNamespaceManager nsmgr = new XmlNamespaceManager (doc.NameTable); XmlUtil.AddDefaultNamespaces (nsmgr); XmlNode entry = doc.SelectSingleNode ("atom:entry", nsmgr); ParseAlbum (entry, nsmgr); }
protected void Connect <T>(string name, string token) where T : AccountConnection { var a = this._context.Current; var c = this._accountConnectionService.GetConnection <T>(name); if (this._context.Current == null || (c != null && c.AccountId == a.ID)) { return; } if (c != null && c.AccountId != a.ID) { throw new CooperknownException(string.Format(this.Lang().sorry_already_connect_another, name)); } if (typeof(T) == typeof(GoogleConnection)) { this._accountConnectionService.Create(c = new GoogleConnection(name, token, a)); } else if (typeof(T) == typeof(GitHubConnection)) { this._accountConnectionService.Create(c = new GitHubConnection(name, token, a)); } //HACK:连接账号时自动关联一切可以关联的信息 this.AssociateEverything(c); }
public PicasaAlbum(GoogleConnection conn, string user, string aid, string authkey) : this(conn) { if (user == null || user == String.Empty) { throw new ArgumentNullException("user"); } if (aid == null || aid == String.Empty) { throw new ArgumentNullException("aid"); } this.user = user; this.id = aid; this.authkey = authkey; string download_link = GDataApi.GetAlbumEntryById(user, id); if (authkey != null && authkey != "") { download_link += "&authkey=" + authkey; } string received = conn.DownloadString(download_link); XmlDocument doc = new XmlDocument(); doc.LoadXml(received); XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); XmlUtil.AddDefaultNamespaces(nsmgr); XmlNode entry = doc.SelectSingleNode("atom:entry", nsmgr); ParseAlbum(entry, nsmgr); }
private PicasaAlbum (GoogleConnection conn) { if (conn == null) throw new ArgumentNullException ("conn"); this.conn = conn; }
/// <summary> /// 刷新GoogleToken信息 /// </summary> private void RefreshConnectionToken(GoogleConnection connection) { _token = _googleTokenService.DeserializeToken(connection.Token); _googleTokenService.RefreshToken(_token); connection.SetToken(_googleTokenService.SerializeToken(_token)); _accountConnectionService.Update(connection); }
private PicasaAlbum(GoogleConnection conn) { if (conn == null) { throw new ArgumentNullException("conn"); } this.conn = conn; }
public void login() { try { connection = new GoogleConnection(GoogleService.Picasa); //ServicePointManager.CertificatePolicy = new NoCheckCertificatePolicy(); connection.Authenticate(this.username, this.password); web = new PicasaWeb(connection); this.loggedIn = true; } catch (Exception) { this.loggedIn = false; } }
public static IServer GetCalendarServer(CalendarTypes calendarTypes, string username = null, string password = null) { IServer server; if (calendarTypes == CalendarTypes.Outlook) { return(new OutlookServer()); } else { IConnection connection; if (calendarTypes == CalendarTypes.Google) { if (File.Exists("token")) { StreamReader sr = new StreamReader("token"); connection = new GoogleConnection(sr.ReadLine()); sr.Close(); } else { connection = refreshGoogleToken(); } server = null; } else { connection = new BasicConnection(username, password); server = null; } if (server == null) { try { server = new CalDav.Client.Server(urlFromCalendarType(calendarTypes), connection, username, password); } catch (Exception ex) { if (ex.Message == "Authentication is required" && connection.GetType().Equals(new GoogleConnection("").GetType())) { connection = refreshGoogleToken(); server = new CalDav.Client.Server(urlFromCalendarType(calendarTypes), connection, username, password); } else { throw ex; } } } return(server); } }
private static IConnection refreshGoogleToken() { IConnection connection; GoogleOAuthForm form = new GoogleOAuthForm(); form.ShowDialog(); connection = new GoogleConnection(form.Result.Token); StreamWriter sw = new StreamWriter("token"); sw.WriteLine(form.Result.Token); sw.Close(); return(connection); }
public void CreateGoole() { var u = this.RandomString(); var c = new GoogleConnection(u, _token, this.CreateAccount()); this._accountConnectionService.Create(c); Assert.Greater(c.ID, 0); var c2 = this._accountConnectionService.GetConnection <GoogleConnection>(u); Assert.IsNotNull(c2); Assert.AreEqual(c2.ID, c.ID); Assert.AreEqual(c2.Name, c.Name); }
public PicasaAlbum (GoogleConnection conn, string aid) : this (conn) { if (conn.User == null) throw new ArgumentException ("Need authentication before being used.", "conn"); if (aid == null || aid == String.Empty) throw new ArgumentNullException ("aid"); this.user = conn.User; this.id = aid; string received = conn.DownloadString (GDataApi.GetAlbumEntryById (conn.User, aid)); XmlDocument doc = new XmlDocument (); doc.LoadXml (received); XmlNamespaceManager nsmgr = new XmlNamespaceManager (doc.NameTable); XmlUtil.AddDefaultNamespaces (nsmgr); XmlNode entry = doc.SelectSingleNode ("atom:entry", nsmgr); ParseAlbum (entry, nsmgr); }
public PicasaWeb(GoogleConnection conn, string username) { if (conn == null) throw new ArgumentNullException ("conn"); if (conn.User == null && username == null) throw new ArgumentException ("The connection should be authenticated OR you should call this constructor with a non-null username argument"); this.conn = conn; this.user = username ?? conn.User; string received = conn.DownloadString (GDataApi.GetGalleryEntry (user)); XmlDocument doc = new XmlDocument (); doc.LoadXml (received); XmlNamespaceManager nsmgr = new XmlNamespaceManager (doc.NameTable); XmlUtil.AddDefaultNamespaces (nsmgr); XmlNode entry = doc.SelectSingleNode ("atom:entry", nsmgr); ParseGallery (entry, nsmgr); }
public PicasaWeb Connect() { System.Console.WriteLine("GoogleAccount.Connect()"); GoogleConnection conn = new GoogleConnection(GoogleService.Picasa); ServicePointManager.CertificatePolicy = new NoCheckCertificatePolicy(); if (unlock_captcha == null || token == null) { conn.Authenticate(username, password); } else { conn.Authenticate(username, password, token, unlock_captcha); token = null; unlock_captcha = null; } connection = conn; PicasaWeb picasa = new PicasaWeb(conn); this.picasa = picasa; return(picasa); }
public PicasaAlbum(GoogleConnection conn, string aid) : this(conn) { if (conn.User == null) { throw new ArgumentException("Need authentication before being used.", "conn"); } if (aid == null || aid == String.Empty) { throw new ArgumentNullException("aid"); } this.user = conn.User; this.id = aid; string received = conn.DownloadString(GDataApi.GetAlbumEntryById(conn.User, aid)); XmlDocument doc = new XmlDocument(); doc.LoadXml(received); XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); XmlUtil.AddDefaultNamespaces(nsmgr); XmlNode entry = doc.SelectSingleNode("atom:entry", nsmgr); ParseAlbum(entry, nsmgr); }
public static IServer GetCalendarServer(CalendarTypes calendarTypes, string username = null, string password = null, string token = null) { IServer server; IConnection connection; if (calendarTypes == CalendarTypes.Google) { connection = new GoogleConnection(token); server = null; } else { connection = new BasicConnection(username, password); server = null; } if (server == null) { try { server = new CalDav.Client.Server(urlFromCalendarType(calendarTypes), connection, username, password); } catch (Exception ex) { if (ex.Message == "Authentication is required" && connection.GetType().Equals(new GoogleConnection("").GetType())) { connection = refreshGoogleToken(); server = new CalDav.Client.Server(urlFromCalendarType(calendarTypes), connection, username, password); } else { throw ex; } } } return(server); }
public PicasaWeb(GoogleConnection conn) : this(conn, null) { }
internal PicasaAlbum(GoogleConnection conn, string user, XmlNode nodeitem, XmlNamespaceManager nsmgr) : this(conn) { this.user = user ?? conn.User; ParseAlbum (nodeitem, nsmgr); }
internal PicasaAlbum(GoogleConnection conn, string user, XmlNode nodeitem, XmlNamespaceManager nsmgr) : this(conn) { this.user = user ?? conn.User; ParseAlbum(nodeitem, nsmgr); }
internal PicasaPicture (GoogleConnection conn, PicasaAlbum album, XmlNode nodeitem, XmlNamespaceManager nsmgr) { this.conn = conn; this.album = album; ParsePicture (nodeitem, nsmgr); }
internal PicasaPicture(GoogleConnection conn, PicasaAlbum album, XmlNode nodeitem, XmlNamespaceManager nsmgr) { this.conn = conn; this.album = album; ParsePicture(nodeitem, nsmgr); }
private void MarkChanged() { connection = null; }
PicasaAlbum(GoogleConnection conn) { Connection = conn ?? throw new ArgumentNullException("conn"); }