Răsfoiți Sursa

Merge remote-tracking branch 'refs/remotes/origin/master'

intirain 4 ani în urmă
părinte
comite
1384eaef02
6 a modificat fișierele cu 45 adăugiri și 1 ștergeri
  1. 24 0
      cmd.c
  2. 1 1
      include/vcc/config.h
  3. 1 0
      include/vcc/interfaces.h
  4. 3 0
      include/vcc/vcc.h
  5. 1 0
      plugins/beep/beep.c
  6. 15 0
      vcc.c

+ 24 - 0
cmd.c

@@ -437,6 +437,30 @@ int do_cmd_swtch(int argc, char **argv) {
 	return 0;
 	return 0;
 }
 }
 
 
+int do_cmd_quits(int argc, char **argv) {
+	int sid;
+
+	switch (argc) {
+	case 1:
+		printf("sid: ");
+		scanf("%d", &sid);
+
+		break;
+	case 2:
+		sscanf(argv[1], "%d", &sid);
+		break;
+
+	default:
+		fprintf(stderr, _("usage: -quits [session-number]\n"));
+		return 1;
+	}
+
+	current_sid = sid;
+	quit_session(current_sid);
+
+	return 0;
+}
+
 
 
 int lself = 0;
 int lself = 0;
 
 

+ 1 - 1
include/vcc/config.h

@@ -1 +1 @@
-#define INSTALL_PATH "/root/vcc"
+#define INSTALL_PATH "/home/ubuntu/vcc"

+ 1 - 0
include/vcc/interfaces.h

@@ -82,6 +82,7 @@ int incr_score(char *username, int incr);
 int vcc_create_session(char *name);
 int vcc_create_session(char *name);
 int get_sessions(void);
 int get_sessions(void);
 int join_session(int sid);
 int join_session(int sid);
+int quit_session(int sid);
 int get_sys_info(void);
 int get_sys_info(void);
 int session_name(int, char *);
 int session_name(int, char *);
 char *getsname(int sid);
 char *getsname(int sid);

+ 3 - 0
include/vcc/vcc.h

@@ -71,6 +71,9 @@
 #define REQ_SYS_INFO 	13
 #define REQ_SYS_INFO 	13
 #define REQ_CTL_SENAME 	14
 #define REQ_CTL_SENAME 	14
 
 
+/* client -> server. quit session */
+#define REQ_CTL_QUITS	15
+
 #define REQ_MAX 	15
 #define REQ_MAX 	15
 
 
 #define REQ_SIZE 	512
 #define REQ_SIZE 	512

+ 1 - 0
plugins/beep/beep.c

@@ -66,6 +66,7 @@ char *beep_hook(struct hook_info *hi) {
 	}
 	}
 
 
 	sprintf(buf, "notify-send \"vcc\" \"vcc: %s: %s\"", hi->usr, p);
 	sprintf(buf, "notify-send \"vcc\" \"vcc: %s: %s\"", hi->usr, p);
+	printf("%s\n", buf);
 
 
 	fprintf(stderr, "\a");
 	fprintf(stderr, "\a");
 	system(buf);
 	system(buf);

+ 15 - 0
vcc.c

@@ -361,6 +361,21 @@ int join_session(int sid) {
 
 
 }
 }
 
 
+int quit_session(int sid) {
+	struct vcc_request req;
+
+	clear_req(&req);
+
+	req.magic = htonl(VCC_MAGIC);
+	req.reqtype = htonl(REQ_CTL_QUITS);
+	req.session = htonl(sid);
+
+	write(fd, &req, REQ_SIZE);
+
+	return 0;
+
+}
+
 int session_name(int sid, char *buf) {
 int session_name(int sid, char *buf) {
 	struct vcc_request req;
 	struct vcc_request req;