Ejemplo n.º 1
0
 public void clear()
 {
     lock (typeof(TelegramSession)) {
         using (IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication()) {
             if (fileStorage.FileExists("/session.dat"))
             {
                 fileStorage.DeleteFile("/session.dat");
             }
         }
         instance = loadIfExists();
     }
 }
Ejemplo n.º 2
0
        public SignupPhone() {
            InitializeComponent();
            session = TelegramSession.Instance;
            flow = new Login(session, "en");
            
            ShowPhoneScene();

            this.BackKeyPress += delegate {
                Application.Current.Terminate();
            };

            Login();
        }
Ejemplo n.º 3
0
 public void clear() {
     lock (typeof (TelegramSession)) {
         using (IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication()) {
             if (fileStorage.FileExists("/session.dat")) {
                 fileStorage.DeleteFile("/session.dat");
             }
         }
         instance = loadIfExists();
     }
 }
Ejemplo n.º 4
0
        private static TelegramSession loadIfExists() {
            TelegramSession session;
            lock(typeof(TelegramSession)) {
                try {
                    using(IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication())
                    using(Stream fileStream = new IsolatedStorageFileStream("session.dat", FileMode.Open, fileStorage))
                    using(BinaryReader fileReader = new BinaryReader(fileStream)) {
                        session = new TelegramSession(fileReader);
                        logger.info("loaded telegram session: {0}", session);
                    }
                } catch(Exception e) {
                    logger.info("error loading session, create new...: {0}", e);

                    logger.info("cleaning contacts");
                    CleanContacts();

                    ulong sessionId = Helpers.GenerateRandomUlong();
                    session = new TelegramSession(sessionId, 0);
                    // prod 173.240.5.1 
                    // test 173.240.5.253
                    TelegramEndpoint endpoint = new TelegramEndpoint("173.240.5.1", 443);
                    TelegramDC dc = new TelegramDC();
                    dc.Endpoints.Add(endpoint);
                    session.Dcs.Add(1, dc);
                    session.SetMainDcId(1);


                    logger.info("created new telegram session: {0}", session);
                }
            }

            return session;
        }
Ejemplo n.º 5
0
 public Login(TelegramSession session, string langCode) {
     this.langCode = langCode;
     this.session = session;
 }
Ejemplo n.º 6
0
 public DialogModelEncrypted(TelegramSession session, BinaryReader reader) : base(session) {
     Read(reader);
 }
Ejemplo n.º 7
0
 public DialogModelEncrypted(TelegramSession session, EncryptedChat chat, byte[] key, long fingerprint, byte[] a) : base(session) {
     this.chat = chat;
     this.key = key;
     this.fingerprint = EncryptedChats.CalculateKeyFingerprint(key);//;fingerprint;
     this.a = a;
 }
Ejemplo n.º 8
0
 public DialogModelEncrypted(TelegramSession session, EncryptedChat chat, byte[] a) : base(session) {
     logger.info("encrypted chat created with a: {0}", BitConverter.ToString(a).Replace("-", "").ToLower());
     this.chat = chat;
     this.a = a;
 }
Ejemplo n.º 9
0
 public DialogModel(TelegramSession session) {
     this.session = session;
     this.messages = new ObservableCollectionUI<MessageModel>();
 }
Ejemplo n.º 10
0
        public DialogPage() {

            session = TelegramSession.Instance;
            model = TelegramSession.Instance.Dialogs.OpenedDialog;
            
            

            InitializeComponent();

            UpdateDataContext();

            DisableEditBox();

            messageEditor.GotFocus += delegate {
                AttachPopup.IsOpen = false;
                EmojiPopup.IsOpen = false;
            };

            messageEditor.LostFocus += delegate {
                if (!EmojiPopup.IsOpen && !AttachPopup.IsOpen)
                    MainPanel.Margin = new Thickness(0, 0, 0, 0);
            };

            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick += TimerOnTick;
            

            messageEditor.TextChanged += MessageEditorOnTextChanged;

            EmojiPanelControl.BackspaceClick += EmojiPanelControlOnBackspaceClick;
            EmojiPanelControl.KeyboardClick += EmojiPanelControlOnKeyboardClick;
            EmojiPanelControl.EmojiGridListSelector.SelectionChanged += EmojiGridListSelectorOnSelectionChanged;

        }
Ejemplo n.º 11
0
 public DialogListModel(TelegramSession session, BinaryReader reader) : this(session) {
     Read(reader);
 }
Ejemplo n.º 12
0
 public DialogListModel(TelegramSession session) {
     this.session = session;
 }
Ejemplo n.º 13
0
        public DialogModelPlain(Peer peer, TelegramSession session)
            : base(session) {
            this.dialog = (DialogConstructor)TL.dialog(peer, 0, 1);

            SubscribeToDialog();
        }
Ejemplo n.º 14
0
        public DialogModelPlain(TelegramSession session, BinaryReader reader) : base(session) {
            Read(reader);

            SubscribeToDialog();
        }
Ejemplo n.º 15
0
 public DialogModelPlain(MessageModelDelivered topMessage, TelegramSession session) : base(session) {
     this.dialog = (DialogConstructor) TL.dialog(topMessage.Peer, topMessage.Id, 1);
     this.messages.Add(topMessage);
     
     SubscribeToDialog();
 }
Ejemplo n.º 16
0
        public DialogModelPlain(Dialog dialog, TelegramSession session, Dictionary<int, MessageModel> messagesMap) : base(session) {
            this.dialog = (DialogConstructor) dialog;
            this.messages.Add(messagesMap[this.dialog.top_message]);

            SubscribeToDialog();
        }