public AccountInfoForm(Yedda.Twitter.Account Account) { _AccountInfo = Account; InitializeComponent(); FillServerList(); PopulateForm(); }
public AccountInfoForm(Yedda.Twitter.Account Account) { _AccountInfo = Account; InitializeComponent(); PockeTwit.Themes.FormColors.SetColors(this); PockeTwit.Localization.XmlBasedResourceManager.LocalizeForm(this); FillServerList(); PopulateForm(); cbRevalidate.Visible = true; cbRevalidate.Checked = false; }
internal void ShowSearchResults(string SearchString, bool saveThem, Yedda.Twitter.PagingMode pagingMode) { LastSearchTerm = SearchString; UpdateHistoryPosition(); ChangeCursor(Cursors.WaitCursor); statList.SetSelectedMenu(SearchMenuItem); HistoryItem i = new HistoryItem(); i.Action = Yedda.Twitter.ActionType.Search; i.Argument = SearchString; History.Push(i); Yedda.Twitter Conn = GetMatchingConnection(CurrentlySelectedAccount); SwitchToList("Search_TimeLine"); statList.ClearVisible(); Library.status[] stats = Manager.SearchTwitter(Conn, SearchString, pagingMode); if (stats != null) { List<Library.status> searchResults = new List<status>(stats); if (saveThem) { LocalStorage.DataBaseUtility.SaveItems(searchResults); } AddStatusesToList(searchResults.ToArray()); statList.AddItem(new MoreResultsItem(this, SearchString, saveThem)); } ChangeCursor(Cursors.Default); }
internal void ShowSpecialTimeLine(ISpecialTimeLine t, Yedda.Twitter.PagingMode pagingMode) { UpdateHistoryPosition(); currentSpecialTimeLine = t; ChangeCursor(Cursors.WaitCursor); HistoryItem i = new HistoryItem(); i.Action = Yedda.Twitter.ActionType.Search; i.Argument = t.name; i.ItemInfo = t; History.Push(i); SwitchToList(t.ListName); statList.ClearVisible(); AddStatusesToList(Manager.GetGroupedTimeLine(t, pagingMode), false); if (t.Timelinetype == SpecialTimeLinesRepository.TimeLineType.SavedSearch) statList.AddItem(new MoreResultsItem(this,t)); ChangeCursor(Cursors.Default); }
void p_ErrorOccured(object sender, Yedda.PictureServiceEventArgs eventArgs) { if (InvokeRequired) { delPictureDone d = new delPictureDone(p_ErrorOccured); this.Invoke(d, sender, eventArgs); } else { Yedda.IPictureService p = (Yedda.IPictureService)sender; p.DownloadFinish -= new Yedda.DownloadFinishEventHandler(p_DownloadFinish); p.ErrorOccured -= new Yedda.ErrorOccuredEventHandler(p_ErrorOccured); Cursor.Current = Cursors.Default; MessageBox.Show("Unable to fetch picture. You may want to try again."); } }
private void SetConnectedMenus(Yedda.Twitter t, StatusItem item) { SetLeftMenu(); UpdateRightMenu(); }
public static status[] Deserialize(string response, Yedda.Twitter.Account Account, StatusTypes TypeOfMessage) { Library.status[] statuses = null; if (string.IsNullOrEmpty(response)) { statuses = new status[0]; } else { if (Account == null || Account.ServerURL.ServerType != Yedda.Twitter.TwitterServer.brightkite) { using (System.IO.StringReader r = new System.IO.StringReader(response)) { statuses = (Library.status[])statusSerializer.Deserialize(r); } } else if (Account.ServerURL.ServerType == Yedda.Twitter.TwitterServer.brightkite) { statuses = FromBrightKite(response); } } if (Account != null) { foreach (Library.status stat in statuses) { stat.Account = Account; stat.TypeofMessage = TypeOfMessage; } } return statuses; }
public static status[] FromDirectReplies(string response, Yedda.Twitter.Account Account) { List<status> resultList = new List<status>(); XmlDocument results = new XmlDocument(); results.LoadXml(response); XmlNodeList entries = results.SelectNodes("//direct_message"); foreach (XmlNode entry in entries) { status newStat = new status(); newStat.text = entry.SelectSingleNode("text").InnerText; newStat.id = entry.SelectSingleNode("id").InnerText; newStat.created_at = entry.SelectSingleNode("created_at").InnerText; string userName = entry.SelectSingleNode("sender/screen_name").InnerText; newStat.user = new User(); newStat.user.screen_name = userName; newStat.user.profile_image_url = entry.SelectSingleNode("sender/profile_image_url").InnerText; newStat.user.location = entry.SelectSingleNode("sender/location").InnerText; newStat.user.description = entry.SelectSingleNode("sender/description").InnerText; resultList.Add(newStat); } foreach (status stat in resultList) { stat.TypeofMessage = StatusTypes.Direct; stat.Account = Account; } return resultList.ToArray(); }
private Library.status[] GetRegularSavedSearchTimeLine(SavedSearchTimeLine searchLine, Yedda.Twitter.PagingMode pagingMode) { var TwitterConn = new Twitter { AccountInfo = { ServerURL = ClientSettings.DefaultAccount.ServerURL, UserName = ClientSettings.DefaultAccount.UserName, Password = ClientSettings.DefaultAccount.Password, Enabled = ClientSettings.DefaultAccount.Enabled } }; status[] items = SearchTwitter(TwitterConn, searchLine.SearchPhrase, pagingMode); return items; }
public static status[] Deserialize(string response, Yedda.Twitter.Account Account) { return Deserialize(response, Account, StatusTypes.Normal); }
public Library.status[] GetUserTimeLine(Yedda.Twitter t, string UserID) { string response = FetchSpecificFromTwitter(t, Yedda.Twitter.ActionType.Show, UserID); if (string.IsNullOrEmpty(response)) { NoData(t.AccountInfo, Yedda.Twitter.ActionType.Show); GlobalEventHandler.CallShowErrorMessage("Communications Error"); return null; } else { ErrorCleared(t.AccountInfo, Yedda.Twitter.ActionType.Show); } return Library.status.Deserialize(response, t.AccountInfo); }
public Library.status[] GetGroupedTimeLine(ISpecialTimeLine t, Yedda.Twitter.PagingMode pagingMode) { TimeLineType timeLineType = TimeLineType.Friends; if(t is SavedSearchTimeLine) { var savedLine = (SavedSearchTimeLine) t; if(!savedLine.autoUpdate) { return GetRegularSavedSearchTimeLine(savedLine, pagingMode); } timeLineType = TimeLineType.Searches; } return LocalStorage.DataBaseUtility.GetList(timeLineType, ClientSettings.MaxTweets, t.GetConstraints()).ToArray(); }
public Library.status[] SearchTwitter(Yedda.Twitter t, string SearchString, Yedda.Twitter.PagingMode pagingMode) { if (pagingMode == Twitter.PagingMode.None) { _lastSearchTerm = SearchString; _currentSearchPageNo = 1; } else { if (_lastSearchTerm != SearchString) _currentSearchPageNo = 1; _lastSearchTerm = SearchString; switch (pagingMode) { case Twitter.PagingMode.Forward: _currentSearchPageNo++; break; case Twitter.PagingMode.Back: _currentSearchPageNo--; break; case Twitter.PagingMode.Neutral: break; } if (_currentSearchPageNo != 1) { SearchString = String.Format("max_id={0}&page={1}&{2}", _firstSearchHitId, _currentSearchPageNo, SearchString); } } string response = FetchSpecificFromTwitter(t, Yedda.Twitter.ActionType.Search, SearchString); if (string.IsNullOrEmpty(response)) { NoData(t.AccountInfo, Yedda.Twitter.ActionType.Search); GlobalEventHandler.CallShowErrorMessage("Communications Error"); return null; } else { ErrorCleared(t.AccountInfo, Yedda.Twitter.ActionType.Search); } var Items = Library.status.DeserializeArrayFromJSON(response, t.AccountInfo, StatusTypes.SearchResult); if (Items == null) return null; if (Items.Length > 0) { foreach (status item in Items) { item.SearchTerm = SearchString; } if (_currentSearchPageNo == 1) { _firstSearchHitId = Items[0].id; } } return Items; }
public static void AuthorizeEcho(HttpWebRequest wc, string oauthToken, string oauthTokenSecret, Yedda.Twitter.OutputFormatType OutputFormatType) { var headers = new Dictionary<string, string>() { //{ "realm", "http://api.twitter.com/" }, { "oauth_consumer_key", _config.ConsumerKey }, { "oauth_nonce", MakeNonce () }, { "oauth_signature_method", "HMAC-SHA1" }, { "oauth_timestamp", MakeTimestamp () }, { "oauth_token", oauthToken }, { "oauth_version", "1.0" } }; string signurl = String.Format("https://api.twitter.com/1/account/verify_credentials.{0}", Yedda.Twitter.GetFormatTypeString(OutputFormatType)); // The signature is not done against the *actual* url, it is done against the verify_credentials.json one string signature = MakeSignature("GET", signurl, headers); string compositeSigningKey = MakeSigningKey(_config.ConsumerSecret, oauthTokenSecret); string oauth_signature = MakeOAuthSignature(compositeSigningKey, signature); headers.Add("oauth_signature", OAuth.PercentEncode(oauth_signature)); wc.Headers.Add("X-Verify-Credentials-Authorization", HeadersToOAuth(headers)); wc.Headers.Add("X-Auth-Service-Provider", signurl); }
void p_DownloadFinish(object sender, Yedda.PictureServiceEventArgs eventArgs) { if (InvokeRequired) { delPictureDone d = new delPictureDone(p_DownloadFinish); this.Invoke(d, sender, eventArgs); } else { Yedda.IPictureService p = (Yedda.IPictureService)sender; p.DownloadFinish -= new Yedda.DownloadFinishEventHandler(p_DownloadFinish); p.ErrorOccured -= new Yedda.ErrorOccuredEventHandler(p_ErrorOccured); Cursor.Current = Cursors.Default; using (ImagePreview ip = new ImagePreview(eventArgs.ReturnMessage, eventArgs.PictureFileName)) { ip.ShowDialog(); } } }
private void CreateFavorite(string ID, Yedda.Twitter.Account AccountInfo) { GetMatchingConnection(AccountInfo).SetFavorite(ID); UpdateRightMenu(); statList.Repaint(); ChangeCursor(Cursors.Default); }
private string FetchSpecificFromTwitter(Yedda.Twitter t, Yedda.Twitter.ActionType TimelineType) { return FetchSpecificFromTwitter(t, TimelineType, null); }
private void FollowUser(Yedda.Twitter.Account account) { StatusItem selectedItem = statList.SelectedItem as StatusItem; if (selectedItem == null) { return; } if (selectedItem.Tweet.user == null) { return; } ChangeCursor(Cursors.WaitCursor); Yedda.Twitter Conn = GetMatchingConnection(selectedItem.Tweet.Account); Conn.FollowUser(selectedItem.Tweet.user.screen_name); FollowingDictionary[Conn].AddUser(selectedItem.Tweet.user); UpdateRightMenu(); ChangeCursor(Cursors.Default); }
private string FetchSpecificFromTwitter(Yedda.Twitter t, Yedda.Twitter.ActionType TimelineType, string AdditionalParameter) { string response = ""; try { switch (TimelineType) { case Yedda.Twitter.ActionType.Direct_Messages: string LastDirectID = LocalStorage.DataBaseUtility.GetLatestItem(t.AccountInfo, TimeLineType.Direct); if (string.IsNullOrEmpty(LastDirectID)) { response = t.GetDirectTimeLineSince(null); } else { response = t.GetDirectTimeLineSince(LastDirectID); } break; case Yedda.Twitter.ActionType.Friends_Timeline: if (!t.BigTimeLines) { response = t.GetFriendsTimeline(Yedda.Twitter.OutputFormatType.XML); } else { string LastStatusID = LocalStorage.DataBaseUtility.GetLatestItem(t.AccountInfo, TimeLineType.Friends); if (string.IsNullOrEmpty(LastStatusID)) { response = t.GetFriendsTimeLineMax(Yedda.Twitter.OutputFormatType.XML); } else { response = t.GetFriendsTimeLineSince(Yedda.Twitter.OutputFormatType.XML, LastStatusID); } } break; case Yedda.Twitter.ActionType.Public_Timeline: response = t.GetPublicTimeline(Yedda.Twitter.OutputFormatType.XML); break; case Yedda.Twitter.ActionType.Replies: if (!t.BigTimeLines) { response = t.GetRepliesTimeLine(Yedda.Twitter.OutputFormatType.XML); } else { string LastReplyID = LocalStorage.DataBaseUtility.GetLatestItem(t.AccountInfo, TimeLineType.Replies); if (string.IsNullOrEmpty(LastReplyID)) { response = t.GetRepliesTimeLine(Yedda.Twitter.OutputFormatType.XML); } else { response = t.GetRepliesTimeLineSince(Yedda.Twitter.OutputFormatType.XML, LastReplyID); } } break; case Yedda.Twitter.ActionType.User_Timeline: response = t.GetUserTimeline(AdditionalParameter, Yedda.Twitter.OutputFormatType.XML); break; case Yedda.Twitter.ActionType.Show: response = t.GetUserTimeline(AdditionalParameter, Yedda.Twitter.OutputFormatType.XML); break; case Yedda.Twitter.ActionType.Favorites: response = t.GetFavorites(); break; case Yedda.Twitter.ActionType.Search: string LastSearchID = LocalStorage.DataBaseUtility.GetLatestItem(t.AccountInfo, TimeLineType.Searches, " statuses.SearchTerm='" + AdditionalParameter + "' AND "); if (string.IsNullOrEmpty(LastSearchID)) { return t.SearchFor(AdditionalParameter); } return t.SearchFor(AdditionalParameter, LastSearchID); } } catch (Exception) { } return response; }
public static status DeserializeSingle(string response, Yedda.Twitter.Account Account) { status s = null; if (string.IsNullOrEmpty(response)) { return new status(); } if (Account == null || (Account.ServerURL.ServerType != Yedda.Twitter.TwitterServer.brightkite && Account.ServerURL.ServerType!= Yedda.Twitter.TwitterServer.pingfm)) { using (System.IO.StringReader r = new System.IO.StringReader(response)) { s = (Library.status)singleSerializer.Deserialize(r); } if (s.text == null) { throw new Exception("Unable to deserialize the response"); } } return s; }
private IPictureService GetMediaService(Yedda.Twitter.TwitterServer server) { IPictureService service; if (server == Twitter.TwitterServer.fanfou) service = PictureServiceFactory.Instance.GetServiceByName("Fanfou"); else service = PictureServiceFactory.Instance.GetServiceByName(ClientSettings.SelectedMediaService); SetPictureEventHandlers(service, true); return service; }
public static status[] DeserializeFromAtom(string response, Yedda.Twitter.Account Account) { List<status> resultList = new List<status>(); XmlDocument results = new XmlDocument(); results.LoadXml(response); XmlNamespaceManager nm = new XmlNamespaceManager(results.NameTable); nm.AddNamespace("google", "http://base.google.com/ns/1.0"); nm.AddNamespace("openSearch", "http://a9.com/-/spec/opensearch/1.1/"); nm.AddNamespace("s", "http://www.w3.org/2005/Atom"); XmlNodeList entries = results.SelectNodes("//s:entry", nm); System.Diagnostics.Debug.WriteLine(entries.Count); try { foreach (XmlNode entry in entries) { status newStat = new status(); newStat.text = entry.SelectSingleNode("s:title", nm).InnerText; newStat.id = entry.SelectSingleNode("s:id", nm).InnerText; newStat.created_at = entry.SelectSingleNode("s:published", nm).InnerText; string userName = entry.SelectSingleNode("s:author/s:name", nm).InnerText; newStat.created_at = entry.SelectSingleNode("s:published", nm).InnerText; string userscreenName = userName.Split(new char[] { ' ' })[0]; newStat.user = new User(); newStat.user.screen_name = userscreenName; newStat.user.profile_image_url = entry.SelectSingleNode("s:link[@type=\"image/png\"]", nm).Attributes["href"].Value; newStat.user.needsFetching = true; resultList.Add(newStat); } } catch { } foreach (status stat in resultList) { stat.TypeofMessage = StatusTypes.SearchResult; stat.Account = Account; } return resultList.ToArray(); }
private Yedda.Twitter GetMatchingConnection(Yedda.Twitter.Account AccountInfo) { if (AccountInfo == null) { return TwitterConnections[0]; } foreach (Yedda.Twitter conn in TwitterConnections) { if (conn.AccountInfo.Equals(AccountInfo)) { return conn; } } return TwitterConnections[0]; }
public static User FromId(string ID, Yedda.Twitter.Account Account) { Yedda.Twitter t = new Yedda.Twitter(); t.AccountInfo = Account; string Response = null; try { Response = t.Show(ID, Yedda.Twitter.OutputFormatType.XML); } catch { User toReturn = new User(); toReturn.screen_name = "PockeTwitUnknownUser"; return toReturn; } try { XmlSerializer s = new XmlSerializer(typeof(User)); if (string.IsNullOrEmpty(Response)) { User toReturn = new User(); toReturn.screen_name = "PockeTwitUnknownUser"; return toReturn; } using (System.IO.StringReader r = new System.IO.StringReader(Response)) { return (User)s.Deserialize(r); } } catch { User toReturn = new User(); toReturn.screen_name = "PockeTwitUnknownUser"; return toReturn; } }
public Library.status[] SearchTwitter(Yedda.Twitter t, string SearchString) { string response = FetchSpecificFromTwitter(t, Yedda.Twitter.ActionType.Search, SearchString); if (string.IsNullOrEmpty(response)) { NoData(t.AccountInfo, Yedda.Twitter.ActionType.Search); GlobalEventHandler.CallShowErrorMessage("Communications Error"); return null; } else { ErrorCleared(t.AccountInfo, Yedda.Twitter.ActionType.Search); } return Library.status.DeserializeFromAtom(response, t.AccountInfo); }