Skip to content
Browse files

GetPublicKey event

  • Loading branch information...
1 parent 1a89238 commit c2b972c876834bac0f27e920267e71bba90b5e7a @Detegr committed Feb 28, 2014
Showing with 20 additions and 0 deletions.
  1. +2 −0 core/core.c
  2. +1 −0 core/event.h
  3. +11 −0 core/handlers.c
  4. +1 −0 core/handlers.h
  5. +4 −0 ui/web/js/tapi2p-backend.js
  6. +1 −0 ui/web/server/tapi2p_websocket.c
View
2 core/core.c
@@ -534,6 +534,7 @@ void* read_thread(void* args)
case FilePartList:
case Metadata:
case FilePart:
+ case GetPublicKey:
event_run_callbacks(e);
break;
}
@@ -766,6 +767,7 @@ int core_start(void)
pipe_event_addlistener(ListPeers, &handlelistpeers, getconfig());
pipe_event_addlistener(Status, &handlestatus, &setupstatus);
pipe_event_addlistener(FileTransferStatus, &handlefiletransferstatus, NULL);
+ pipe_event_addlistener(GetPublicKey, &handlegetpublickey, NULL);
event_addlistener(RequestFileTransfer, &handlefiletransfer, NULL);
event_addlistener(RequestFileTransferLocal, &handlefiletransferlocal, NULL);
event_addlistener(RequestFilePart, &handlefilepartrequest, NULL);
View
1 core/event.h
@@ -23,6 +23,7 @@ typedef enum {
RequestFilePartList,
FilePartList,
FileTransferStatus,
+ GetPublicKey,
EventCount // For iterating through eventtypes
} EventType;
View
11 core/handlers.c
@@ -603,3 +603,14 @@ void handlefiletransferstatus(pipeevt_t *e, void *data)
json_decref(root);
free(statuses);
}
+
+void handlegetpublickey(pipeevt_t *e, void *data)
+{
+ static struct pubkey selfkey;
+ if(pubkey_load(&selfkey, selfkeypath_pub()))
+ {
+ fprintf(stderr, "Failed to load private key. Have you set up tapi2p correctly?\n");
+ return;
+ }
+ pipe_event_send_back_to_caller(e, selfkey.keyastext, strlen(selfkey.keyastext));
+}
View
1 core/handlers.h
@@ -17,5 +17,6 @@ void handleaddfile(evt_t* e, void* data);
void handlesetup(pipeevt_t *e, void *data);
void handlestatus(pipeevt_t *e, void *data);
void handlefiletransferstatus(pipeevt_t *e, void *data);
+void handlegetpublickey(pipeevt_t *e, void *data);
#endif
View
4 ui/web/js/tapi2p-backend.js
@@ -30,6 +30,10 @@ function Tapi2pBackend(onopen, onerror, onmessage) {
"AddFile": ENUM_BASE++,
"Setup": ENUM_BASE++,
"Status": ENUM_BASE++,
+ "RequestFilePartList": ENUM_BASE++,
+ "FilePartList": ENUM_BASE++,
+ "FileTransferStatus": ENUM_BASE++,
+ "GetPublicKey": ENUM_BASE++,
"Hello": -1 // Special for web ui only
};
View
1 ui/web/server/tapi2p_websocket.c
@@ -285,6 +285,7 @@ int main()
event_addlistener(PeerConnected, &coreeventhandler, NULL);
event_addlistener(PeerDisconnected, &coreeventhandler, NULL);
event_addlistener(Status, &coreeventhandler, NULL);
+ event_addlistener(GetPublicKey, &coreeventhandler, NULL);
eventsystem_start(corefd);
struct libwebsocket_context* ctx;

0 comments on commit c2b972c

Please sign in to comment.
Something went wrong with that request. Please try again.