aboutsummaryrefslogtreecommitdiff
path: root/close_direct_conversations
diff options
context:
space:
mode:
authorJulien Dessaux2019-08-06 15:44:18 +0200
committerJulien Dessaux2019-08-06 17:42:06 +0200
commitfea924350b6ba50dc0cb0e5e133cbbd914137e61 (patch)
tree68e119dec63829356db8614204d0a6b4bb7e5221 /close_direct_conversations
parentCosmetics (diff)
downloadrocket-cli-client-fea924350b6ba50dc0cb0e5e133cbbd914137e61.tar.gz
rocket-cli-client-fea924350b6ba50dc0cb0e5e133cbbd914137e61.tar.bz2
rocket-cli-client-fea924350b6ba50dc0cb0e5e133cbbd914137e61.zip
Added a proper subscriptions listing for the direct conversations closer
Diffstat (limited to '')
-rw-r--r--close_direct_conversations/CMakeLists.txt6
-rw-r--r--close_direct_conversations/main.c (renamed from close_im/main.c)17
2 files changed, 21 insertions, 2 deletions
diff --git a/close_direct_conversations/CMakeLists.txt b/close_direct_conversations/CMakeLists.txt
new file mode 100644
index 0000000..7aba3e4
--- /dev/null
+++ b/close_direct_conversations/CMakeLists.txt
@@ -0,0 +1,6 @@
+file(GLOB_RECURSE SOURCES *.c)
+
+ADD_EXECUTABLE(rocket_close_direct_conversations ${SOURCES})
+target_link_libraries(rocket_close_direct_conversations common restapi)
+
+install(TARGETS rocket_close_direct_conversations DESTINATION bin)
diff --git a/close_im/main.c b/close_direct_conversations/main.c
index c54ab25..0938982 100644
--- a/close_im/main.c
+++ b/close_direct_conversations/main.c
@@ -1,12 +1,19 @@
-#include "common/util.h"
#include <stdlib.h>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include "common/config.h"
+#include "common/util.h"
#include "restapi/auth.h"
#include "restapi/im.h"
+#include "restapi/subscriptions.h"
+
+void print_subscription(const struct subscription* sub)
+{
+ if (sub->type == SUBSCRIPTION_DIRECT)
+ printf("\t%s\n", sub->name);
+}
int main(void)
{
@@ -51,10 +58,16 @@ int main(void)
}
if (restapi_login(login, password) == 0) {
+ struct subscription* subscriptions = restapi_subscriptions_get();
+
+ printf("Active direct conversations :\n");
+ common_subscriptions_const_walk(subscriptions, &print_subscription);
+ common_subscriptions_free(subscriptions);
+
while(1) {
char* buff = NULL;
size_t len2;
- printf("IM to close: ");
+ printf("Direct conversation to close: ");
ssize_t entry = getline(&buff, &len2, stdin);
if (entry > 1) {
buff[entry-1] = 0;