Ejemplo n.º 1
0
        public string GetAvatarFilename(int friendNumber)
        {
            var publicKey = _tox.GetFriendPublicKey(friendNumber);

            if (publicKey == null)
            {
                return(null);
            }

            return(Path.Combine(AvatarDataPath, publicKey.ToString() + ".png"));
        }
Ejemplo n.º 2
0
        void newReqReceived(Package receivedPackage, int friendNum)
        {
            string mcontentCache = "";

            if (mPackageCache.ContainsKey(receivedPackage.uuid))
            {
                mcontentCache = mPackageCache[receivedPackage.uuid].content;
            }
            mcontentCache += receivedPackage.content;
            // check if this is a response
            if (mPendingReqList.ContainsKey(receivedPackage.uuid))
            {
                mPendingReqList[receivedPackage.uuid](JsonConvert.DeserializeObject <ToxResponse>(mcontentCache));
                mPendingReqList.Remove(receivedPackage.uuid);
                return;
            }

            ToxRequest newReq = JsonConvert.DeserializeObject <ToxRequest>(mcontentCache);

            Task.Factory.StartNew(async() =>
            {
                // send response to http server
                Console.WriteLine("new Req: " + JsonConvert.SerializeObject(newReq));
                ToxResponse mRes = await RequestProxy.sendRequest(this, newReq);
                sendResponse(mRes, tox.GetFriendPublicKey(friendNum));
            });
        }
Ejemplo n.º 3
0
        public FriendListViewModel(Tox tox)
        {
            var friends = new SourceList <uint>();

            foreach (var friend in tox.Friends)
            {
                friends.Add(friend);
                tox.AddFriendNoRequest(tox.GetFriendPublicKey(friend, out _), out _);
            }

            this.Add = ReactiveCommand.Create <uint>(friendNumber =>
            {
                friends.Add(friendNumber);
            });

            ReadOnlyObservableCollection <FriendListEntryViewModel> entries;

            friends.Connect()
            .Transform(number => new FriendListEntryViewModel(tox, number))
            .Bind(out entries)
            .Subscribe();

            this.Friends = entries;

            this.Friends.ToObservableChangeSet()
            .MergeMany(x => x.Remove)
            .Subscribe(number =>
            {
                if (tox.DeleteFriend(number, out _))
                {
                    friends.Remove(number);
                }
            });
        }
Ejemplo n.º 4
0
        private void HandleAvatarTransfer(ToxEventArgs.FileSendRequestEventArgs e)
        {
            var    ID   = Tox.GetFriendPublicKey(e.FriendNumber).ToString();
            string path = Utilities.GetAvatarPath(e.FriendNumber, Tox);

            IncomingFileTransfer ft = new IncomingFileTransfer(e, Tox, path);

            ft.OnComplete += (vm) =>
            {
                GetContactViewModelByFriendNumber(e.FriendNumber).Image = path;
            };
        }
Ejemplo n.º 5
0
        public void TestToxFriendPublicKey()
        {
            var error     = ToxErrorFriendGetPublicKey.Ok;
            var publicKey = _tox2.GetFriendPublicKey(0, out error);

            if (error != ToxErrorFriendGetPublicKey.Ok)
            {
                Assert.Fail("Could not get friend public key, error: {0}", error);
            }

            var error2 = ToxErrorFriendByPublicKey.Ok;
            int friend = _tox2.GetFriendByPublicKey(publicKey, out error2);

            if (friend != 0 || error2 != ToxErrorFriendByPublicKey.Ok)
            {
                Assert.Fail("Could not get friend by public key, error: {0}, friend: {1}", error2, friend);
            }
        }
Ejemplo n.º 6
0
 public static string GetAvatarPath(int number, Tox tox)
 {
     return(Path.GetFullPath(Path.Combine(AvatarPath, tox.GetFriendPublicKey(number).ToString() + ".png")));
 }