From 89e2dcf83fa3901090893e98c17708e279dea47f Mon Sep 17 00:00:00 2001 From: Tom Marshall Date: Mon, 24 Nov 2014 15:11:41 -0800 Subject: recovery: Initial dialog implementation Implement two types of dialogs: info and error. Info dialogs are intended to show that an operation is in progress and cannot be interrupted. Error dialogs are intended to show that an error occurred. The user must respond by dismissing the dialog with any input (a swipe or keypress). Dialogs may be initiated internally within the UI code or externally via a named local socket. Dialogs created via socket are presumed to be info and may not be dismissed. When the client socket is closed, the dialog automatically dismisses. Initial implementation shows dialogs for adb backup and restore. Future work will show dialogs for all errors and lengthy operations. Change-Id: Icefea12ec0fd70fb487d54aa2eb1cae9dd451355 --- messagesocket.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 messagesocket.h (limited to 'messagesocket.h') diff --git a/messagesocket.h b/messagesocket.h new file mode 100644 index 0000000..5a4c67d --- /dev/null +++ b/messagesocket.h @@ -0,0 +1,40 @@ +#ifndef MESSAGESOCKET_H +#define MESSAGESOCKET_H + +class MessageSocket +{ +private: + // Unimplemented + MessageSocket(const MessageSocket&); + MessageSocket& operator=(const MessageSocket&); + +public: + MessageSocket() : _sock(-1) {} + ~MessageSocket() { Close(); } + int fd() const { return _sock; } + + bool ServerInit(); + MessageSocket* Accept(); + ssize_t Read(void* buf, size_t len); + + bool ClientInit(); + bool Show(const char* message); + bool Dismiss(); + + void Close(); + +private: + explicit MessageSocket(int fd) : _sock(fd) {} + + bool send_command(const char* command); + + int _sock; +}; + +extern int dialog_server_init(); +extern int dialog_client_init(); +extern int dialog_accept(int fd); +extern int dialog_show(int fd); +extern int dialog_dismiss(int fd); + +#endif -- cgit v1.1