コード例 #1
0
        public virtual async Task ProcessUserPublicKey(UserPublicKey content)
        {
            var contact = db.GetContact(content.UserId);

            if (contact == null)
            {
                if (content.PublicKeyData != null)
                {
                    contact = new ChadderContact()
                    {
                        Name              = "Anonymous",
                        PictureId         = null,
                        Picture           = db.GetPicture(null),
                        PublicKeyBookData = content.PublicKeyData,
                        UserId            = content.UserId,
                        Type              = RelationshipType.FRIENDS,
                    };
                    await db.AddContact(contact, false);
                }
            }
            else
            {
                if (content.PublicKeyData == null) // Delete Friend
                {
                    await db.DeleteContact(contact);
                }
                else
                {
                    contact.UpdatePublicKey(content.PublicKeyData);
                    await sqlDB.UpdateAsync(contact);
                }
            }
        }
コード例 #2
0
        static public ChatFragment OpenChat(ChadderContact contact)
        {
            var result = new ChatFragment();

            result.Arguments = new Bundle();
            result.Arguments.PutString(EXTRA_CONTACT_ID, contact.UserId);
            return(result);
        }
コード例 #3
0
        public async Task <ChadderError> DeleteContact(ChadderContact contact)
        {
            var result = await AuthorizedRequest <BasicResponse>(Connection.ContactHub, "DeleteContact", contact.UserId);

            if (result.Error == ChadderError.OK)
            {
                await db.DeleteContact(contact);
            }
            return(result.Error);
        }
コード例 #4
0
        public async Task <ChadderError> ReportContact(ChadderContact contact, string reason)
        {
            var response = await AuthorizedRequest <BasicResponse>(Connection.ContactHub, "ReportUser", contact.UserId, reason, null);

            if (response.Error == ChadderError.OK)
            {
                return(await SetFriendType(contact, RelationshipType.BLOCKED));
            }
            return(response.Error);
        }
コード例 #5
0
 static public ViewProfileFragment ViewProfile(ChadderContact Profile)
 {
     if (Profile.IsTemporary)
     {
         TempProfile = Profile;
         return(ViewProfile((string)null));
     }
     else
     {
         return(ViewProfile(Profile.UserId));
     }
 }
コード例 #6
0
        public async Task <ChadderError> SetFriendType(ChadderContact contact, RelationshipType type)
        {
            if (contact.Type == type)
            {
                return(ChadderError.OK);
            }
            var result = await AuthorizedRequest <BasicResponse>(Connection.ContactHub, "SetFriendType", contact.UserId, type);

            if (result.Error == ChadderError.OK)
            {
                contact.Type = type;
                await sqlDB.UpdateAsync(contact);
            }
            return(result.Error);
        }
コード例 #7
0
        public async Task <BasicResponse <ChadderContact> > GetUserInfo(string id)
        {
            var response = await AuthorizedRequest <BasicResponse <ContactInfo> >(Connection.ContactHub, "GetUserInfo", id);

            var result = new BasicResponse <ChadderContact>();

            result.Error          = response.Error;
            result.InnerException = response.InnerException;
            result.Time           = response.Time;
            if (response.Error == ChadderError.OK)
            {
                result.Extra = ChadderContact.Create(response.Extra, this, true);
            }
            return(result);
        }
コード例 #8
0
        public async void ToggleBlock(ChadderContact contact)
        {
            ChadderApp.UIHelper.ShowLoading();
            ChadderError result = ChadderError.OK;

            if (contact.Type == Data.RelationshipType.FRIENDS)
            {
                result = await Source.SetFriendType(contact, Data.RelationshipType.BLOCKED);
            }
            else
            {
                result = await Source.SetFriendType(contact, Data.RelationshipType.FRIENDS);
            }
            ChadderApp.UIHelper.HideLoading();
            ShowErrorIfNotOk(result);
        }
コード例 #9
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            var id = Arguments.GetString(EXTRA_CONTACT_ID, null);

            if (id == null)
            {
                Profile = TempProfile;
            }
            else
            {
                Profile = ChadderUI.Source.db.Contacts.FirstOrDefault(i => i.UserId == id);
            }
            if (Profile == null)
            {
                SupportFragmentManager.PopBackStack();
            }
        }
コード例 #10
0
 public Task SetPublicKeyStatus(ChadderContact contact, PublicKeyStatus status)
 {
     contact.KeyStatus = status;
     return(sqlDB.UpdateAsync(contact));
 }
コード例 #11
0
        public async Task <Content> EncryptForUser(Content content, ChadderContact contact)
        {
            var key = new ECDHUser(db.LocalUser.UserId, contact.UserId);

            return(await AES256WithKey.Encrypt(this, key, content));
        }
コード例 #12
0
 public async void ReportContact(ChadderContact contact)
 {
 }