static private void GetEvents(Journal.OptionsRow or, ILJServer iLJ, ref SyncItemCollection sic, ref SyncItemCollection deletedsic, ref EventCollection ec) { // for an explanation of this algorithm, see // http://www.livejournal.com/community/lj_clients/143312.html // note that this is a very painful algorithm. it will loop an extra time for each // deleted syncitem that getevents doesn't return an event for. if LJ decides to revise // how they return syncitems, this algorithm can be made more efficient. int total = sic.Count; while (sic.Count > 0) { SyncItem oldest = sic.GetOldest(); DateTime oldestTime = DateTime.Parse(oldest.time, CultureInfo.InvariantCulture).AddSeconds(-1); GetChallengeResponse gcr = iLJ.GetChallenge(); string auth_response = MD5Hasher.Compute(gcr.challenge + or.HPassword); GetEventsParams gep = new GetEventsParams(or.UserName, "challenge", gcr.challenge, auth_response, 1, 0, 0, 0, "syncitems", oldestTime.ToString(_datetimeformat), 0, 0, 0, 0, string.Empty, 0, "unix", (or.IsUseJournalNull() ? string.Empty : or.UseJournal)); GetEventsResponse ger; socb(new SyncOperationEventArgs(SyncOperation.GetEvents, total - sic.Count, total)); ger = iLJ.GetEvents(gep); // remove this item in case it isn't returned by getevents // this signifies that the item has been deleted // this also ensures we don't get stuck in an endless loop sic.Remove(oldest); sic.RemoveDownloaded(ger.events); deletedsic.RemoveDownloaded(ger.events); ec.AddRange(ger.events); } }
static private void SessionGenerate(Journal.OptionsRow or, ILJServer iLJ, ref SessionGenerateResponse sgr) { // a session needs to be generated to talk to the livejournal web server // right now there is no export comments method on xmlrpc, so we get comments the ol' fashioned way - // with a web request GetChallengeResponse gcr = iLJ.GetChallenge(); string auth_response = MD5Hasher.Compute(gcr.challenge + or.HPassword); SessionGenerateParams sgp = new SessionGenerateParams(or.UserName, "challenge", gcr.challenge, auth_response, 1, "long", 0); sgr = iLJ.SessionGenerate(sgp); }