Esempio n. 1
0
        public void GetUserPhotosAsync(TLInputUserBase userId, TLInt offset, TLLong maxId, TLInt limit, Action <TLPhotosBase> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLGetUserPhotos {
                UserId = userId, Offset = offset, MaxId = maxId, Limit = limit
            };

            SendInformativeMessage("photos.getUserPhotos", obj, callback, faultCallback);
        }
Esempio n. 2
0
        public void DeleteContactAsync(TLInputUserBase id, Action <TLLinkBase> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLDeleteContact {
                Id = id
            };

            SendInformativeMessage <TLLinkBase>("contacts.deleteContact", obj, result => _cacheService.SyncUserLink(result, callback), faultCallback);
        }
        public void EditChatAdminAsync(TLInputChannelBase channel, TLInputUserBase userId, TLChannelParticipantRoleBase role, Action <TLBool> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLEditAdmin {
                Channel = channel, UserId = userId, Role = role
            };

            SendInformativeMessage("channels.editAdmin", obj, callback, faultCallback);
        }
        public void RequestCallAsync(TLInputUserBase userId, TLInt randomId, TLString gaHash, TLPhoneCallProtocol protocol, Action <TLPhonePhoneCall> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLRequestCall {
                UserId = userId, RandomId = randomId, GAHash = gaHash, Protocol = protocol
            };

            SendInformativeMessage("phone.requestCall", obj, callback, faultCallback);
        }
Esempio n. 5
0
        public void BlockAsync(TLInputUserBase id, Action <TLBool> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLBlock {
                Id = id
            };

            SendInformativeMessage("contacts.block", obj, callback, faultCallback);
        }
        public void UnblockAsync(TLInputUserBase id, Action <bool> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLContactsUnblock {
                Id = id
            };

            const string caption = "contacts.unblock";

            SendInformativeMessage(caption, obj, callback, faultCallback);
        }
        public BotResultsCollection(IMTProtoService protoService, TLInputUserBase bot, TLInputPeerBase peer, TLInputGeoPointBase geoPoint, string query)
        {
            _protoService = protoService;
            _bot          = bot;
            _peer         = peer;
            _geoPoint     = geoPoint;
            _query        = query;

            _nextOffset = string.Empty;
        }
        public void RequestCallAsync(TLInputUserBase userId, int randomId, byte[] gaHash, Action <TLPhonePhoneCall> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLPhoneRequestCall {
                UserId = userId, RandomId = randomId, GAHash = gaHash, Protocol = GetPhoneCallProtocol()
            };

            const string caption = "phone.requestCall";

            SendInformativeMessage(caption, obj, callback, faultCallback);
        }
        public void DeleteContactAsync(TLInputUserBase id, Action <TLContactsLink> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLContactsDeleteContact {
                Id = id
            };

            const string caption = "contacts.deleteContact";

            SendInformativeMessage <TLContactsLink>(caption, obj, result => _cacheService.SyncUserLink(result, callback), faultCallback);
        }
Esempio n. 10
0
        public void ReportSpamAsync(TLInputChannelBase channel, TLInputUserBase userId, TLVector <int> id, Action <bool> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLChannelsReportSpam {
                Channel = channel, UserId = userId, Id = id
            };

            const string caption = "channels.reportSpam";

            SendInformativeMessage <bool>(caption, obj, callback, faultCallback);
        }
Esempio n. 11
0
        public void GetUserPhotosAsync(TLInputUserBase userId, int offset, long maxId, int limit, Action <TLPhotosPhotosBase> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLPhotosGetUserPhotos {
                UserId = userId, Offset = offset, MaxId = maxId, Limit = limit
            };

            const string caption = "photos.getUserPhotos";

            SendInformativeMessage(caption, obj, callback, faultCallback);
        }
Esempio n. 12
0
        public void GetFullUserAsync(TLInputUserBase id, Action <TLUserFull> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLGetFullUser {
                Id = id
            };

            SendInformativeMessage <TLUserFull>("users.getFullUser", obj, userFull =>
            {
                _cacheService.SyncUser(userFull, result => callback.SafeInvoke(result));
            }, faultCallback);
        }
Esempio n. 13
0
        public void RequestEncryptionAsync(TLInputUserBase userId, TLInt randomId, TLString ga, Action <TLEncryptedChatBase> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLRequestEncryption {
                UserId = userId, RandomId = randomId, G_A = ga
            };

            SendInformativeMessage <TLEncryptedChatBase>("messages.requestEncryption", obj,
                                                         encryptedChat =>
            {
                _cacheService.SyncEncryptedChat(encryptedChat, callback.SafeInvoke);
            },
                                                         faultCallback);
        }
        public void GetParticipantAsync(TLInputChannelBase inputChannel, TLInputUserBase userId, Action<TLChannelsChannelParticipant> callback, Action<TLRPCError> faultCallback = null)
        {
            var obj = new TLGetParticipant { Channel = inputChannel, UserId = userId };

            const string caption = "channels.getParticipant";
            SendInformativeMessage<TLChannelsChannelParticipant>(caption, obj, result =>
            {
                _cacheService.SyncUsers(result.Users, r => { });

                callback.SafeInvoke(result);
            }, 
            faultCallback);
        }
Esempio n. 15
0
        public UserPhotosViewModel(IMTProtoService protoService, TLUserFull userFull, TLUser user)
            : base(protoService, null, null)
        {
            //Items = new MvxObservableCollection<GalleryItem>();
            //Initialize(user);

            _peer = user.ToInputUser();
            _user = user;

            Items = new MvxObservableCollection <GalleryItem> {
                new GalleryPhotoItem(userFull.ProfilePhoto as TLPhoto, user)
            };
            SelectedItem = Items[0];
            FirstItem    = Items[0];

            Initialize(user, userFull.ProfilePhoto.Id);
        }
 private void DeleteUserHistoryAsync(TLChannel channel, TLInputUserBase userId, Action <TLAffectedHistory> callback, Action <TLRPCError> faultCallback = null)
 {
     MTProtoService.DeleteUserHistoryAsync(channel, userId,
                                           result =>
     {
         if (result.Offset.Value > 0)
         {
             DeleteUserHistoryAsync(channel, userId, callback, faultCallback);
         }
         else
         {
             callback.SafeInvoke(result);
         }
     },
                                           error =>
     {
         Telegram.Api.Helpers.Execute.ShowDebugMessage("channels.deleteUserHistory error " + error);
     });
 }
Esempio n. 17
0
 public ItemsCollection(IMTProtoService protoService, TLInputUserBase userId)
 {
     _protoService = protoService;
     _userId       = userId;
 }
Esempio n. 18
0
        public void StartOutgoingCall(TLInputUserBase userId)
        {
            var salt   = new Byte[256];
            var random = new SecureRandom();

            random.NextBytes(salt);

            var version      = _lastVersion ?? new TLInt(0);
            var randomLength = new TLInt(256);

            _mtProtoService.GetDHConfigAsync(version, randomLength,
                                             result =>
            {
                ConfigureDeviceForCall();
                ShowNotifications();
                StartConnectionSound();
                DispatchStateChanged(PhoneCallState.STATE_REQUESTING);

                _eventAggregator.Publish(new PhoneCallEventArgs("NotificationCenter.didStartedCall"));

                var dhConfig = result as TLDHConfig;
                if (dhConfig != null)
                {
                    if (!TLUtils.CheckPrime(dhConfig.P.Data, dhConfig.G.Value))
                    {
                        CallFailed();
                        return;
                    }

                    _secretP      = dhConfig.P;
                    _secretG      = dhConfig.G;
                    _secretRandom = dhConfig.Random;
                }

                for (var i = 0; i < 256; i++)
                {
                    salt[i] = (byte)(salt[i] ^ _secretRandom.Data[i]);
                }

                var gaBytes = MTProtoService.GetGB(salt, _secretG, _secretP);

                var protocol = new TLPhoneCallProtocol
                {
                    Flags        = new TLInt(0),
                    UdpP2P       = true,
                    UdpReflector = true,
                    MinLayer     = new TLInt(CALL_MIN_LAYER),
                    MaxLayer     = new TLInt(CALL_MAX_LAYER)
                };
                _ga        = gaBytes;
                var gaHash = Utils.ComputeSHA256(_ga);

                _mtProtoService.RequestCallAsync(userId, TLInt.Random(), TLString.FromBigEndianData(gaHash), protocol,
                                                 result2 =>
                {
                    _call = result2;
                    _aOrB = salt;
                    DispatchStateChanged(PhoneCallState.STATE_WAITING);
                    //if (_endCallAfterRequest)
                    //{
                    //    Hangup();
                    //    return;
                    //}
                },
                                                 error2 =>
                {
                });
            },
                                             error =>
            {
                Helpers.Execute.ShowDebugMessage("messages.getDHConfig error " + error);
                CallFailed();
            });
        }