Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-client-uwp
Commits
e72856b7
Commit
e72856b7
authored
Oct 30, 2016
by
Nicolas Jager
Browse files
contact : add capability to delete contact and conversation file
Change-Id: Ia2781ffcbbf1929b5535cb7fd16e2f36eff5eb33 Tuleap: #1285
parent
1ba34442
Changes
13
Hide whitespace changes
Inline
Side-by-side
Contact.cpp
View file @
e72856b7
...
...
@@ -136,6 +136,19 @@ Contact::DestringifyConversation(String^ data)
}
}
void
RingClientUWP
::
Contact
::
deleteConversationFile
()
{
StorageFolder
^
localfolder
=
ApplicationData
::
Current
->
LocalFolder
;
String
^
messagesFile
=
".messages
\\
"
+
GUID_
+
".json"
;
// refacto : Utils::fileExists fails here if the file doesn't exist, code below should replace fileExist everywhere
create_task
(
localfolder
->
TryGetItemAsync
(
messagesFile
)).
then
([](
IStorageItem
^
storageFile
)
{
if
(
storageFile
)
storageFile
->
DeleteAsync
();
});
}
void
Contact
::
saveConversationToFile
()
{
...
...
Contact.h
View file @
e72856b7
...
...
@@ -95,6 +95,7 @@ internal:
void
saveConversationToFile
();
String
^
StringifyConversation
();
void
DestringifyConversation
(
String
^
data
);
void
deleteConversationFile
();
protected:
void
NotifyPropertyChanged
(
String
^
propertyName
);
...
...
ContactsViewModel.cpp
View file @
e72856b7
...
...
@@ -173,6 +173,20 @@ ContactsViewModel::Destringify(String^ data)
}
}
void
RingClientUWP
::
ViewModel
::
ContactsViewModel
::
deleteContact
(
Contact
^
contact
)
{
unsigned
int
index
;
auto
itemsList
=
SmartPanelItemsViewModel
::
instance
->
itemsList
;
auto
item
=
SmartPanelItemsViewModel
::
instance
->
_selectedItem
;
if
(
contactsList_
->
IndexOf
(
contact
,
&
index
))
{
contact
->
deleteConversationFile
();
contactsList_
->
RemoveAt
(
index
);
}
saveContactsToFile
();
}
void
RingClientUWP
::
ViewModel
::
ContactsViewModel
::
OnincomingMessage
(
Platform
::
String
^
callId
,
Platform
::
String
^
payload
)
{
...
...
ContactsViewModel.h
View file @
e72856b7
...
...
@@ -27,6 +27,7 @@ namespace RingClientUWP
/* delegates */
delegate
void
ContactAdded
(
Contact
^
);
delegate
void
ContactDeleted
(
Contact
^
);
namespace
ViewModel
{
public
ref
class
ContactsViewModel
sealed
...
...
@@ -49,6 +50,7 @@ internal:
void
openContactsFromFile
();
String
^
Stringify
();
void
Destringify
(
String
^
data
);
void
deleteContact
(
Contact
^
contact
);
/* properties */
property
Vector
<
Contact
^>^
contactsList
...
...
@@ -61,6 +63,7 @@ internal:
/* events */
event
ContactAdded
^
contactAdded
;
event
ContactDeleted
^
contactDeleted
;
private:
ContactsViewModel
();
// singleton
...
...
MainPage.xaml.cpp
View file @
e72856b7
...
...
@@ -70,6 +70,9 @@ MainPage::MainPage()
smartPanel
->
summonVideoPage
+=
ref
new
RingClientUWP
::
SummonVideoPage
(
this
,
&
RingClientUWP
::
MainPage
::
OnsummonVideoPage
);
auto
videoPage
=
dynamic_cast
<
VideoPage
^>
(
_videoFrame_
->
Content
);
videoPage
->
pressHangUpCall
+=
ref
new
RingClientUWP
::
PressHangUpCall
(
this
,
&
RingClientUWP
::
MainPage
::
OnpressHangUpCall
);
auto
messageTextFrame
=
dynamic_cast
<
MessageTextPage
^>
(
_messageTextFrame_
->
Content
);
messageTextFrame
->
closeMessageTextPage
+=
ref
new
RingClientUWP
::
CloseMessageTextPage
(
this
,
&
RingClientUWP
::
MainPage
::
OncloseMessageTextPage
);
DisplayInformation
^
displayInformation
=
DisplayInformation
::
GetForCurrentView
();
dpiChangedtoken
=
(
displayInformation
->
DpiChanged
+=
ref
new
TypedEventHandler
<
DisplayInformation
^
,
...
...
@@ -398,3 +401,10 @@ MainPage::BeginExtendedExecution()
}
});
}
void
RingClientUWP
::
MainPage
::
OncloseMessageTextPage
()
{
auto
smartPanel
=
dynamic_cast
<
SmartPanel
^>
(
_smartPanel_
->
Content
);
smartPanel
->
unselectContact
();
}
MainPage.xaml.h
View file @
e72856b7
...
...
@@ -74,5 +74,6 @@ private:
void
OnsummonVideoPage
();
void
OnpressHangUpCall
();
void
OnstateChange
(
Platform
::
String
^
callId
,
CallStatus
state
,
int
code
);
void
OncloseMessageTextPage
();
};
}
MessageTextPage.xaml
View file @
e72856b7
...
...
@@ -134,6 +134,7 @@
VerticalAlignment="Center"
FontSize="20"
Margin="20,0" />
<StackPanel Orientation="Horizontal">
<ComboBox x:Name="_associableAccountsList_">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="local:Account">
...
...
@@ -143,6 +144,10 @@
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Button x:Name="_deleteContact_"
Content="delete"
Click="_deleteContact__Click"/>
</StackPanel>
</StackPanel>
</StackPanel>
...
...
MessageTextPage.xaml.cpp
View file @
e72856b7
...
...
@@ -178,4 +178,15 @@ void RingClientUWP::Views::MessageTextPage::OnSelectionChanged(Platform::Object
{
auto
account
=
dynamic_cast
<
Account
^>
(
_associableAccountsList_
->
SelectedItem
);
SmartPanelItemsViewModel
::
instance
->
_selectedItem
->
_contact
->
_accountIdAssociated
=
account
->
accountID_
;
}
\ No newline at end of file
}
void
RingClientUWP
::
Views
::
MessageTextPage
::
_deleteContact__Click
(
Platform
::
Object
^
sender
,
Windows
::
UI
::
Xaml
::
RoutedEventArgs
^
e
)
{
auto
item
=
SmartPanelItemsViewModel
::
instance
->
_selectedItem
;
auto
contact
=
item
->
_contact
;
closeMessageTextPage
();
ContactsViewModel
::
instance
->
deleteContact
(
contact
);
SmartPanelItemsViewModel
::
instance
->
removeItem
(
item
);
}
MessageTextPage.xaml.h
View file @
e72856b7
...
...
@@ -21,6 +21,8 @@
namespace
RingClientUWP
{
delegate
void
CloseMessageTextPage
();
namespace
Views
{
...
...
@@ -45,6 +47,9 @@ public:
void
updatePageContent
();
void
scrollDown
();
internal:
event
CloseMessageTextPage
^
closeMessageTextPage
;
private:
void
_sendBtn__Click
(
Platform
::
Object
^
sender
,
Windows
::
UI
::
Xaml
::
RoutedEventArgs
^
e
);
void
_messageTextBox__KeyDown
(
Platform
::
Object
^
sender
,
Windows
::
UI
::
Xaml
::
Input
::
KeyRoutedEventArgs
^
e
);
...
...
@@ -52,6 +57,7 @@ private:
void
OnincomingMessage
(
Platform
::
String
^
callId
,
Platform
::
String
^
payload
);
void
OnSelectionChanged
(
Platform
::
Object
^
sender
,
Windows
::
UI
::
Xaml
::
Controls
::
SelectionChangedEventArgs
^
e
);
void
_deleteContact__Click
(
Platform
::
Object
^
sender
,
Windows
::
UI
::
Xaml
::
RoutedEventArgs
^
e
);
};
}
}
SmartPanel.xaml.cpp
View file @
e72856b7
...
...
@@ -173,6 +173,11 @@ RingClientUWP::Views::SmartPanel::updatePageContent()
_upnpState_
->
IsOn
=
accountListItem
->
_account
->
_upnpState
;
}
void
RingClientUWP
::
Views
::
SmartPanel
::
unselectContact
()
{
_smartList_
->
SelectedItem
=
nullptr
;
}
void
RingClientUWP
::
Views
::
SmartPanel
::
_accountsMenuButton__Checked
(
Object
^
sender
,
RoutedEventArgs
^
e
)
{
_shareMenuButton_
->
IsChecked
=
false
;
...
...
SmartPanel.xaml.h
View file @
e72856b7
...
...
@@ -83,6 +83,7 @@ public ref class SmartPanel sealed
public:
SmartPanel
();
void
updatePageContent
();
void
unselectContact
();
internal:
enum
class
Mode
{
Minimized
,
Normal
};
...
...
SmartPanelItemsViewModel.cpp
View file @
e72856b7
...
...
@@ -75,4 +75,12 @@ SmartPanelItemsViewModel::getIndex(Contact^ contact)
break
;
}
return
i
;
}
\ No newline at end of file
}
void
RingClientUWP
::
ViewModel
::
SmartPanelItemsViewModel
::
removeItem
(
SmartPanelItem
^
item
)
{
unsigned
int
index
;
if
(
itemsList
->
IndexOf
(
item
,
&
index
))
itemsList
->
RemoveAt
(
index
);
}
SmartPanelItemsViewModel.h
View file @
e72856b7
...
...
@@ -46,6 +46,7 @@ internal:
SmartPanelItem
^
findItem
(
Contact
^
contact
);
unsigned
int
getIndex
(
String
^
callId
);
unsigned
int
getIndex
(
Contact
^
contact
);
void
removeItem
(
SmartPanelItem
^
item
);
property
Vector
<
SmartPanelItem
^>^
itemsList
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment