public void TestGetUpdates() { var upgradeUrl = CreateUpgradeServer(Resources.mock_serv); var app1 = m_ServHelper.MockAppAssembly(new Version(1, 0)); var app2 = m_ServHelper.MockAppAssembly(new Version(1, 2, 0, 0)); var app3 = m_ServHelper.MockAppAssembly(new Version(1, 2, 1, 0)); var app4 = m_ServHelper.MockAppAssembly(new Version(1, 2, 1, 0)); var srv1 = new UpdatesService(app1, new UpdatesUrlAttribute(upgradeUrl)); var srv2 = new UpdatesService(app2, new UpdatesUrlAttribute(upgradeUrl)); var srv3 = new UpdatesService(app3, new UpdatesUrlAttribute(upgradeUrl)); var srv4 = new UpdatesService(app4, new UpdatesUrlAttribute(upgradeUrl + "_invalid")); var res1 = srv1.GetUpdates(); var res2 = srv2.GetUpdates(); var res3 = srv3.GetUpdates(); Assert.AreEqual(new Version(1, 2, 1, 0), res1.Item1); Assert.AreEqual("https://www.xarial-app4.com/whats-new", res1.Item2); Assert.AreEqual("https://www.xarial-app4.com/upgrade", res1.Item3); Assert.AreEqual(new Version(1, 2, 1, 0), res2.Item1); Assert.AreEqual("https://www.xarial-app4.com/whats-new", res2.Item2); Assert.AreEqual("https://www.xarial-app4.com/upgrade", res2.Item3); Assert.IsNull(res3); Assert.ThrowsException <UpdatesCheckException>(() => srv4.CheckForUpdates()); }
public LoadingPageViewModel(SettingsService settings, PlatformService platform, ApiService api, ArchivesService archives, UpdatesService updates, ISettingsStorageService settingsStorage) { Settings = settings; Platform = platform; Api = api; Archives = archives; Updates = updates; SettingsStorage = settingsStorage; }
// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching(object sender, LaunchingEventArgs e) { BlueBrush = (SolidColorBrush)Application.Current.Resources["PhoneAccentBrush"]; //BlueColorBrush"]; APIErrorHandler = new APIErrorHandler(); LongPollService = new LongPollService(); PushNotifications = new PushNotifications(); UpdatesService = new UpdatesService(); EntityService = new EntityService(); }
private void RunAsync(Action callback) { var deviceInfoService = new DeviceInfoService(GetInitConnection(), true, "BackgroundDifferenceLoader", _id); var eventAggregator = new TelegramEventAggregator(); var cacheService = new InMemoryCacheService(eventAggregator); var updatesService = new UpdatesService(cacheService, eventAggregator); var transportService = new TransportService(); var connectionService = new ConnectionService(deviceInfoService); var publicConfigService = new MockupPublicConfigService(); var manualResetEvent = new ManualResetEvent(false); var mtProtoService = new MTProtoService(deviceInfoService, updatesService, cacheService, transportService, connectionService, publicConfigService); mtProtoService.Initialized += (o, e) => { var lastTime = TLUtils.OpenObjectFromMTProtoFile <TLInt>(_differenceTimeSyncRoot, Constants.DifferenceTimeFileName); if (lastTime != null) { var now = TLUtils.DateToUniversalTimeTLInt(mtProtoService.ClientTicksDelta, DateTime.Now); if (lastTime.Value + Constants.DifferenceMinInterval > now.Value) { manualResetEvent.Set(); return; } } var clientState = TLUtils.OpenObjectFromMTProtoFile <TLState>(_stateRoot, Constants.StateFileName); _results = TLUtils.OpenObjectFromMTProtoFile <TLVector <TLDifference> >(_differenceFileSyncRoot, Constants.DifferenceFileName) ?? new TLVector <TLDifference>(); var state = GetState(clientState, _results); if (state != null) { GetDifferenceAsync(mtProtoService, state, () => manualResetEvent.Set()); } else { manualResetEvent.Set(); } }; mtProtoService.InitializationFailed += (o, e) => { manualResetEvent.Set(); }; mtProtoService.Initialize(); #if DEBUG manualResetEvent.WaitOne(15000); #else manualResetEvent.WaitOne(15000); #endif callback.SafeInvoke(); }
public void Initialize(BackgroundTaskDeferral deferral) { if (_connection == null & _protoService == null) { VoIPCallTask.Log("Mediator initialized", "Creating proto service"); var deviceInfoService = new DeviceInfoService(); var eventAggregator = new TelegramEventAggregator(); var cacheService = new InMemoryCacheService(eventAggregator); var updatesService = new UpdatesService(cacheService, eventAggregator); var transportService = new TransportService(); var connectionService = new ConnectionService(deviceInfoService); var statsService = new StatsService(); var protoService = new MTProtoService(deviceInfoService, updatesService, cacheService, transportService, connectionService, statsService); protoService.Initialized += (s, args) => { VoIPCallTask.Log("ProtoService initialized", "waiting for updates"); updatesService.LoadStateAndUpdate(() => { VoIPCallTask.Log("Difference processed", "Difference processed"); if (_phoneCall == null) { VoIPCallTask.Log("Difference processed", "No call found in difference"); if (_systemCall != null) { _systemCall.NotifyCallEnded(); } } }); }; eventAggregator.Subscribe(this); protoService.Initialize(); _protoService = protoService; _transportService = transportService; } else { VoIPCallTask.Log("Mediator initialized", "_connection is null: " + (_connection == null)); } _deferral = deferral; _initialized = true; ProcessUpdates(); }
// Code to execute when the application is activated (brought to foreground) // This code will not execute when the application is first launched private void Application_Activated(object sender, ActivatedEventArgs e) { if (LongPollService == null) { LongPollService = new LongPollService(); } if (PushNotifications == null) { PushNotifications = new PushNotifications(); } if (APIErrorHandler == null) { APIErrorHandler = new APIErrorHandler(); } if (UpdatesService == null) { UpdatesService = new UpdatesService(); } if (EntityService == null) { EntityService = new EntityService(); } if (!_settings.IsPushOn) { // If timer has gone, so we can turn on Push notifications. if (DateTime.Now >= _settings.PushTurnOnTime) { _settings.IsPushOn = true; App.Current.PushNotificationsSwitchTimer.Dispose(); } else { // Turn on push notifications when time occurs. TimeSpan temp = _settings.PushTurnOnTime - DateTime.Now; PushNotificationsSwitchTimer = new Timer(state => { _settings.IsPushOn = true; App.Current.PushNotificationsSwitchTimer.Dispose(); }, null, Convert.ToInt32(temp.TotalMilliseconds), -1); } } }
public void TestInitialization() { var mock1 = m_ServHelper.MockAppAssembly(new Version(1, 0)); var srv1 = new UpdatesService(mock1, new UpdatesUrlAttribute("https://www.xarial.net/test")); var appMock4 = m_ServHelper.MockAppAssembly(null); var appMock5 = m_ServHelper.MockAppAssembly(new Version(2, 1, 3, 5)); var srv2 = new UpdatesService(appMock5, new UpdatesUrlAttribute("https://www.xarial.net/test")); Assert.AreEqual("https://www.xarial.net/test", srv1.ServerUrl); Assert.AreEqual(new Version(2, 1, 3, 5), srv2.Version); Assert.ThrowsException <CheckForUpdatesDataException>(() => new UpdatesService(appMock4, new UpdatesUrlAttribute("https://www.xarial.net/test"))); Assert.ThrowsException <CheckForUpdatesDataException>(() => new UpdatesService(appMock5, new UpdatesUrlAttribute("invalid url"))); }
public void Run(IBackgroundTaskInstance taskInstance) { var deferral = taskInstance.GetDeferral(); var data = Toast.GetData(taskInstance); if (data != null) { if (data.ContainsKey("QuickMessage")) { var deviceInfoService = new DeviceInfoService(); var eventAggregator = new TelegramEventAggregator(); var cacheService = new InMemoryCacheService(eventAggregator); var updatesService = new UpdatesService(cacheService, eventAggregator); var transportService = new TransportService(); var connectionService = new ConnectionService(deviceInfoService); var statsService = new StatsService(); var manualResetEvent = new ManualResetEvent(false); var protoService = new MTProtoService(deviceInfoService, updatesService, cacheService, transportService, connectionService, statsService); protoService.Initialized += (s, args) => { var text = data["QuickMessage"]; var messageText = text.Replace("\r\n", "\n").Replace('\v', '\n').Replace('\r', '\n'); var entitiesBase = Utils.GetEntities(ref messageText); var replyToMsgId = 0; var inputPeer = default(TLInputPeerBase); if (data.ContainsKey("from_id")) { inputPeer = new TLInputPeerUser { UserId = int.Parse(data["from_id"]), AccessHash = long.Parse(data["access_hash"]) }; } else if (data.ContainsKey("channel_id")) { inputPeer = new TLInputPeerChannel { ChannelId = int.Parse(data["channel_id"]), AccessHash = long.Parse(data["access_hash"]) }; replyToMsgId = data.ContainsKey("msg_id") ? int.Parse(data["msg_id"]) : 0; } else if (data.ContainsKey("chat_id")) { inputPeer = new TLInputPeerChat { ChatId = int.Parse(data["chat_id"]) }; replyToMsgId = data.ContainsKey("msg_id") ? int.Parse(data["msg_id"]) : 0; } TLVector <TLMessageEntityBase> entities = null; if (entitiesBase != null) { entities = new TLVector <TLMessageEntityBase>(entitiesBase); } var obj = new TLMessagesSendMessage { Peer = inputPeer, ReplyToMsgId = replyToMsgId, Message = messageText, Entities = entities, IsBackground = true, RandomId = TLLong.Random() }; protoService.SendInformativeMessageInternal <TLUpdatesBase>("messages.sendMessage", obj, result => { manualResetEvent.Set(); }, faultCallback: fault => { // TODO: alert user? manualResetEvent.Set(); }, fastCallback: () => { manualResetEvent.Set(); }); //var date = TLUtils.DateToUniversalTimeTLInt(protoService.ClientTicksDelta, DateTime.Now); //var message = TLUtils.GetMessage(SettingsHelper.UserId, inputPeer, TLMessageState.Sending, true, true, date, text, new TLMessageMediaEmpty(), TLLong.Random(), replyToMsgId); //var history = cacheService.GetHistory(inputPeer, 1); //cacheService.SyncSendingMessage(message, null, async (m) => //{ // await protoService.SendMessageAsync(message, () => // { // // TODO: fast callback // }); // manualResetEvent.Set(); //}); }; protoService.InitializationFailed += (s, args) => { manualResetEvent.Set(); }; //cacheService.Init(); protoService.Initialize(); manualResetEvent.WaitOne(15000); } } deferral.Complete(); }
private void SendReply(TLInputPeerBase inputPeer, TLString message, TLInt msgId) { if (msgId == null) { return; } if (TLString.IsNullOrEmpty(message)) { return; } var actionInfo = TLUtils.OpenObjectFromMTProtoFile <TLVector <TLActionInfo> >(_actionInfoSyncRoot, Constants.ActionQueueFileName) ?? new TLVector <TLActionInfo>(); var count = actionInfo.Count; Log("send count=" + count); var peerChannel = inputPeer as TLInputPeerChannel; var readHistory = peerChannel != null ? (TLObject) new TLReadChannelHistory { Channel = new TLInputChannel { ChannelId = peerChannel.ChatId, AccessHash = peerChannel.AccessHash }, MaxId = msgId } : new TLReadHistory { Peer = inputPeer, MaxId = msgId }; var readHistoryActionInfo = new TLActionInfo(); readHistoryActionInfo.SendBefore = new TLInt(0); readHistoryActionInfo.Action = readHistory; actionInfo.Add(readHistoryActionInfo); var sendMessage = new TLSendMessage(); sendMessage.Flags = new TLInt(0); sendMessage.Peer = inputPeer; sendMessage.Message = message; sendMessage.RandomId = TLLong.Random(); var sendMessageActionInfo = new TLActionInfo(); sendMessageActionInfo.SendBefore = new TLInt(0); sendMessageActionInfo.Action = sendMessage; actionInfo.Add(sendMessageActionInfo); TLUtils.SaveObjectToMTProtoFile(new object(), Constants.ActionQueueFileName, actionInfo); if (actionInfo.Count > 0) { var deviceInfoService = new DeviceInfoService(GetInitConnection(), true, "InteractiveNotificationsBackgroundTask", _id); var eventAggregator = new TelegramEventAggregator(); var cacheService = new InMemoryCacheService(eventAggregator); var updatesService = new UpdatesService(cacheService, eventAggregator); var transportService = new TransportService(); var connectionService = new ConnectionService(deviceInfoService); var publicConfigService = new MockupPublicConfigService(); var manualResetEvent = new ManualResetEvent(false); Log("before init"); var requestsToRemove = new List <TLObject>(); var mtProtoService = new MTProtoService(deviceInfoService, updatesService, cacheService, transportService, connectionService, publicConfigService); mtProtoService.Initialized += async(o, e) => { Log("init completed"); var actionsString = new StringBuilder(); foreach (var info in actionInfo) { actionsString.AppendLine(info.ToString()); } Log(actionsString.ToString()); var sendMessageActions = new List <TLObject>(); const int maxActionCount = 10; var currentCount = 0; foreach (var ai in actionInfo) { if (TLUtils.IsValidAction(ai.Action) && currentCount < maxActionCount) { currentCount++; sendMessageActions.Add(ai.Action); } } if (sendMessageActions.Count > 0) { mtProtoService.SendActionsAsync(sendMessageActions, (request, result) => // will be invoked for each sent action { requestsToRemove.Add(request); var sendingMessages = mtProtoService.SendingMessages; Log("send completed count=" + sendingMessages, () => { if (sendingMessages == 0) { _clearActionInfoFile = true; manualResetEvent.Set(); } }); }, error => { Log(string.Format("send error={0}\n{1}", error, error.Exception), async() => { await Task.Delay(TimeSpan.FromSeconds(1.0)); manualResetEvent.Set(); }); }); } else { manualResetEvent.Set(); } }; mtProtoService.InitializationFailed += (o, e) => { Log("init failed"); manualResetEvent.Set(); }; mtProtoService.Initialize(); #if DEBUG manualResetEvent.WaitOne(); #else manualResetEvent.WaitOne(15000); #endif if (_clearActionInfoFile) { Log("clear"); lock (_actionInfoSyncRoot) { var actions = actionInfo; foreach (var o in requestsToRemove) { MTProtoService.RemoveActionInfoCommon(actions, o); } TLUtils.SaveObjectToMTProtoFile(_actionInfoSyncRoot, Constants.ActionQueueFileName, actions); } } } }
private void UpdateNotifySettings(TLInputPeerBase inputPeer, TLInt muteUntil) { var deviceInfoService = new DeviceInfoService(GetInitConnection(), true, "InteractiveNotificationsBackgroundTask", _id); var eventAggregator = new TelegramEventAggregator(); var cacheService = new InMemoryCacheService(eventAggregator); var updatesService = new UpdatesService(cacheService, eventAggregator); var transportService = new TransportService(); var connectionService = new ConnectionService(deviceInfoService); var publicConfigService = new MockupPublicConfigService(); var manualResetEvent = new ManualResetEvent(false); Log("before init"); var mtProtoService = new MTProtoService(deviceInfoService, updatesService, cacheService, transportService, connectionService, publicConfigService); mtProtoService.Initialized += (o, e) => { Log("init completed"); mtProtoService.GetNotifySettingsAsync(new TLInputNotifyPeer { Peer = inputPeer }, result => { Log("getNotifySettings completed", () => { var peerNotifySettings = result as TLPeerNotifySettings; if (peerNotifySettings != null) { if (muteUntil.Value < int.MaxValue) { muteUntil = TLUtils.DateToUniversalTimeTLInt(mtProtoService.ClientTicksDelta, DateTime.Now.AddSeconds(muteUntil.Value)); } var inputPeerNotifySettings = new TLInputPeerNotifySettings78 { Flags = new TLInt(0), MuteUntil = muteUntil, Sound = peerNotifySettings.Sound, }; mtProtoService.UpdateNotifySettingsAsync(new TLInputNotifyPeer { Peer = inputPeer }, inputPeerNotifySettings, result2 => { Log("setNotifySettings completed", () => { manualResetEvent.Set(); }); }, error2 => { Log(string.Format("setNotifySettings error={0}\n{1}", error2, error2.Exception), async() => { await Task.Delay(TimeSpan.FromSeconds(1.0)); manualResetEvent.Set(); }); }); } else { manualResetEvent.Set(); } }); }, error => { Log(string.Format("getNotifySettings error={0}\n{1}", error, error.Exception), async() => { await Task.Delay(TimeSpan.FromSeconds(1.0)); manualResetEvent.Set(); }); }); }; mtProtoService.InitializationFailed += (o, e) => { Log("init failed"); manualResetEvent.Set(); }; mtProtoService.Initialize(); #if DEBUG manualResetEvent.WaitOne(); #else manualResetEvent.WaitOne(15000); #endif }
public void Run(IBackgroundTaskInstance taskInstance) { Telegram.Logs.Log.WriteSync = true; taskInstance.Canceled += OnTaskCanceled; var deferral = taskInstance.GetDeferral(); var stopwatch = Stopwatch.StartNew(); var task = taskInstance.Task; var name = task != null ? task.Name : null; Log("start " + name); if (!_appOpenMutex.WaitOne(0)) { Log("cancel", deferral.Complete); return; } _appOpenMutex.ReleaseMutex(); Log("release mutex"); var isAuthorized = SettingsHelper.GetValue <bool>(Constants.IsAuthorizedKey); if (!isAuthorized) { Log("cancel isAuthorized=false", deferral.Complete); return; } Log("isAuthorized=true"); var deviceInfoService = new DeviceInfoService(GetInitConnection(), true, "MessageSchedulerBackgroundTask", _id); var eventAggregator = new TelegramEventAggregator(); var cacheService = new InMemoryCacheService(eventAggregator); var updatesService = new UpdatesService(cacheService, eventAggregator); var transportService = new TransportService(); var connectionService = new ConnectionService(deviceInfoService); var manualResetEvent = new ManualResetEvent(false); Log("before init"); var requestsToRemove = new List <TLObject>(); var mtProtoService = new MTProtoService(deviceInfoService, updatesService, cacheService, transportService, connectionService); mtProtoService.Initialized += async(o, e) => { Log("init completed"); var actionInfos = mtProtoService.GetActionInfoFromFile(); var count = actionInfos != null ? actionInfos.Count : 0; Log("send count=" + count); if (actionInfos != null && actionInfos.Count > 0) { var actionsString = new StringBuilder(); foreach (var info in actionInfos) { actionsString.AppendLine(info.ToString()); } Log(actionsString.ToString()); var sendMessageActions = new List <TLObject>(); const int maxActionCount = 10; var currentCount = 0; foreach (var actionInfo in actionInfos) { if (TLUtils.IsValidAction(actionInfo.Action) && currentCount < maxActionCount) { currentCount++; sendMessageActions.Add(actionInfo.Action); } } if (sendMessageActions.Count > 0) { await Task.Delay(TimeSpan.FromSeconds(3.0)); mtProtoService.SendActionsAsync(sendMessageActions, (request, result) => // will be invoked for each sent action { requestsToRemove.Add(request); var sendingMessages = mtProtoService.SendingMessages; Log("send completed count=" + sendingMessages, () => { if (sendingMessages == 0) { _clearActionInfoFile = true; manualResetEvent.Set(); } }); }, error => { Log(string.Format("send error={0}\n{1}", error, error.Exception), async() => { await Task.Delay(TimeSpan.FromSeconds(1.0)); manualResetEvent.Set(); }); }); } else { manualResetEvent.Set(); } } else { manualResetEvent.Set(); } }; mtProtoService.InitializationFailed += (o, e) => { Log("init failed"); manualResetEvent.Set(); }; mtProtoService.Initialize(); #if DEBUG manualResetEvent.WaitOne(); #else manualResetEvent.WaitOne(15000); #endif if (_clearActionInfoFile) { Log("clear"); mtProtoService.RemoveActionInfoFromFile(requestsToRemove); } Log("stop " + stopwatch.Elapsed, deferral.Complete); }
private void StartPart2(string mutexName, string[] remainingArgs) { IAnimationService animationService; Memory.Initialize(); CultureInfo info = AppSettings.Instance.UI.Language.Value; Thread.CurrentThread.CurrentUICulture = info; CultureInfo.DefaultThreadCurrentUICulture = info; AppSettings.Instance.UI.Language.Value = info; PdnResources.Culture = info; AppSettings.Instance.UI.ErrorFlagsAtStartup.Value = AppSettings.Instance.UI.ErrorFlags.Value; UIUtil.IsGetMouseMoveScreenPointsEnabled = AppSettings.Instance.UI.EnableSmoothMouseInput.Value; if (!OS.VerifyFrameworkVersion(4, 6, 0, OS.FrameworkProfile.Full)) { string message = PdnResources.GetString("Error.FXRequirement"); MessageBoxUtil.ErrorBox(null, message); string fxurl = "http://www.microsoft.com/en-us/download/details.aspx?id=40773"; () => ShellUtil.LaunchUrl2(null, fxurl).Eval <bool>().Observe(); } else if (!OS.VerifyWindowsVersion(6, 1, 1)) { string str4 = PdnResources.GetString("Error.OSRequirement"); MessageBoxUtil.ErrorBox(null, str4); } else if (!Processor.IsFeaturePresent(ProcessorFeature.SSE)) { string str5 = PdnResources.GetString("Error.SSERequirement"); MessageBoxUtil.ErrorBox(null, str5); } else { string str; if (MultithreadedWorkItemDispatcher.IsSingleThreadForced && PdnInfo.IsFinalBuild) { throw new PaintDotNet.InternalErrorException("MultithreadedWorkItemDispatcher.IsSingleThreadForced shouldn't be true for Final builds!"); } if (RefTrackedObject.IsFullRefTrackingEnabled && PdnInfo.IsFinalBuild) { throw new PaintDotNet.InternalErrorException("Full ref tracking should not be enabled for non-expiring builds!"); } PaintDotNet.Base.AssemblyServices.RegisterProxies(); PaintDotNet.Core.AssemblyServices.RegisterProxies(); PaintDotNet.Framework.AssemblyServices.RegisterProxies(); ObjectRefProxy.CloseRegistration(); remainingArgs = TryRemoveArg(remainingArgs, "/showCrashLog=", out str); if (!string.IsNullOrWhiteSpace(str)) { DialogResult?nullable = null; try { string fullPath = Path.GetFullPath(str); if (File.Exists(fullPath)) { nullable = new DialogResult?(CrashManager.ShowCrashLogDialog(fullPath)); } } catch (Exception exception) { try { MessageBox.Show(exception.ToString(), null, MessageBoxButtons.OK, MessageBoxIcon.Hand); } catch (Exception exception2) { Environment.FailFast(null, exception2); } } DialogResult?nullable2 = nullable; DialogResult oK = DialogResult.OK; if ((((DialogResult)nullable2.GetValueOrDefault()) == oK) ? nullable2.HasValue : false) { string[] args = new string[] { "/sleep=1000" }; StartNewInstance(null, false, args); } } else { string str2; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Startup.OnCurrentDomainUnhandledException); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, true); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, false); Application.ThreadException += new ThreadExceptionEventHandler(Startup.OnApplicationThreadException); this.canUseCrashDialog = true; remainingArgs = TryRemoveArg(remainingArgs, "/test", out str2); if (str2 != null) { PdnInfo.IsTestMode = true; } SingleInstanceManager disposeMe = new SingleInstanceManager(mutexName); animationService = null; try { DirectWriteFactory.DefaultDirectWriteSettingsController defaultDirectWriteSettingsController; DrawingContext.DefaultDrawingContextSettingsController defaultDrawingContextSettingsController; IDisposable updatesServiceShutdown; IUpdatesServiceHost updatesServiceHost; PdnSynchronizationContext pdnSyncContext; if (!disposeMe.IsFirstInstance) { disposeMe.FocusFirstInstance(); foreach (string str7 in remainingArgs) { disposeMe.SendInstanceMessage(str7, 30); } disposeMe.Dispose(); disposeMe = null; } else { CleanupService.Initialize(); ResourcesService.Initialize(); UserFilesService.Initialize(); UserPalettesService.Initialize(); animationService = AnimationService.Initialize(); animationService.IsEnabled = true; Document.Initialize(PdnInfo.Version); Layer.Initialize(PdnResources.GetString("Layer.BackgroundLayer.DefaultName")); Effect.SetDefaultServiceProviderValueFactory(effect => new ServiceProviderForEffects()); defaultDirectWriteSettingsController = DirectWriteFactory.GetDefaultSettingsController(); defaultDirectWriteSettingsController.DefaultCulture = AppSettings.Instance.UI.Language.Value; AppSettings.Instance.UI.Language.ValueChangedT += (sender, e) => (defaultDirectWriteSettingsController.DefaultCulture = e.NewValue); AeroColors.CurrentScheme = AppSettings.Instance.UI.AeroColorScheme.Value; AppSettings.Instance.UI.AeroColorScheme.ValueChangedT += (sender, e) => (AeroColors.CurrentScheme = e.NewValue); defaultDrawingContextSettingsController = DrawingContext.GetDefaultSettingsController(); defaultDrawingContextSettingsController.DefaultTextAntialiasMode = AppSettings.Instance.UI.DefaultTextAntialiasMode.Value; AppSettings.Instance.UI.DefaultTextAntialiasMode.ValueChangedT += delegate(object sender, ValueChangedEventArgs <TextAntialiasMode> e) { defaultDrawingContextSettingsController.DefaultTextAntialiasMode = e.NewValue; foreach (Form form in Application.OpenForms) { form.PerformLayoutRecursiveDepthFirst("TextAntialiasMode"); form.Invalidate(true); } }; defaultDrawingContextSettingsController.DefaultTextRenderingMode = AppSettings.Instance.UI.DefaultTextRenderingMode.Value; AppSettings.Instance.UI.DefaultTextRenderingMode.ValueChangedT += delegate(object sender, ValueChangedEventArgs <TextRenderingMode> e) { defaultDrawingContextSettingsController.DefaultTextRenderingMode = e.NewValue; foreach (Form form in Application.OpenForms) { form.PerformLayoutRecursiveDepthFirst("TextRenderingMode"); form.Invalidate(true); } }; PaintDotNet.IndirectUI.ControlInfo.Initialize(Assembly.GetExecutingAssembly()); PdnBaseForm.SetStaticHelpRequestedHandler(delegate(object sender, HelpEventArgs e) { HelpService.Instance.ShowHelp(sender as IWin32Window); e.Handled = true; }); Control control = new Control(); SynchronizationContext current = SynchronizationContext.Current; PdnSynchronizationContextController controller = PdnSynchronizationContext.Install(new WaitForMultipleObjectsExDelegate(WaitHelper.WaitForMultipleObjectsEx), new SleepExDelegate(WaitHelper.SleepEx)); pdnSyncContext = controller.Instance; this.mainForm = new MainForm(remainingArgs); updatesServiceHost = this.mainForm.CreateUpdatesServiceHost(); updatesServiceShutdown = null; EventHandler initUpdatesOnShown = null; initUpdatesOnShown = delegate(object sender, EventArgs e) { this.mainForm.Shown -= initUpdatesOnShown; updatesServiceShutdown = UpdatesService.Initialize(updatesServiceHost); }; this.mainForm.Shown += initUpdatesOnShown; this.mainForm.SingleInstanceManager = disposeMe; disposeMe = null; int num = (int)Math.Floor((double)8.3333333333333339); int intervalMs = (int)Math.Floor((double)50.0); using (AnimationTimerUpdateThread timerThread = new AnimationTimerUpdateThread(intervalMs, false)) { < > c__DisplayClass20_1 class_3;
static void Main(string[] args) { var manualResetEvent = new ManualResetEvent(false); ////var transport = new HttpTransport(string.Empty); ////transport.SetAddress("http://95.142.192.65/api", 80, () => manualResetEvent.Set()); //var transport = new TcpTransport(); //transport.SetAddress("95.142.192.65", 80, () => manualResetEvent.Set()); //manualResetEvent.WaitOne(); //IAuthorizationHelper authHelper = new AuthorizationHelper(Transport); //authHelper.InitAsync(res =>{}); manualResetEvent.Reset(); var cacheService = new InMemoryCacheService(null); var updatesService = new UpdatesService(cacheService, null); MTProtoService.Salt = new TLLong(0); var service = new MTProtoService(updatesService, cacheService, new TransportService()); service.Initialized += (o, e) => manualResetEvent.Set(); manualResetEvent.WaitOne(); var phoneNumber = new TLString("79996610000"); service.SendCodeAsync(phoneNumber, TLSmsType.Code, sentCode => { var phoneCodeHash = sentCode.PhoneCodeHash; service.SignInAsync(phoneNumber, phoneCodeHash, new TLString("11111"), authorization => { //TLUtils.WriteLine("Auth: " + TLUtils.MessageIdString(authorization.Expires)); service.GetDialogsAsync(new TLInt(0), new TLInt(0), new TLInt(int.MaxValue), dialogs => { }, er2 => { }); //service.GetContactsAsync( // new TLString(""), // contactsResult => // { // var contacts = contactsResult as TLContacts; // if (contacts != null) // { // var contact = contacts.Contacts[0]; // service.GetHistoryAsync(new TLInputPeerContact{UserId = contact.UserId}, new TLInt(0), new TLInt(0), new TLInt(int.MaxValue), // messagesResult => // { // }, // er2 => { }); // } // }, // er => // { // }); }); }); Console.ReadKey(); }