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); } } }
static public ChatFragment OpenChat(ChadderContact contact) { var result = new ChatFragment(); result.Arguments = new Bundle(); result.Arguments.PutString(EXTRA_CONTACT_ID, contact.UserId); return(result); }
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); }
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); }
static public ViewProfileFragment ViewProfile(ChadderContact Profile) { if (Profile.IsTemporary) { TempProfile = Profile; return(ViewProfile((string)null)); } else { return(ViewProfile(Profile.UserId)); } }
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); }
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); }
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); }
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(); } }
public Task SetPublicKeyStatus(ChadderContact contact, PublicKeyStatus status) { contact.KeyStatus = status; return(sqlDB.UpdateAsync(contact)); }
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)); }
public async void ReportContact(ChadderContact contact) { }