Mercurial > hg
comparison mcabber/src/screen.c @ 35:a8ceaa3005fd
[/trunk] Changeset 51 by mikael
Work on libjabber integration. This is a big patch...
* Remove socket.[ch] server.[ch]
We have now fully switched to libjabber.
* Roster is fetched, and buddies are added to the buddylist
* Can send/receive messages using libjabber
* Presence messages are handled. I have added statuses, as there only were
online / offline statuses.
* Use halfdelay to have a non-blocking getch().
And use a timeout in jb_main().
* Use utf8_{encode,decode}
author | mikael |
---|---|
date | Mon, 04 Apr 2005 19:13:58 +0000 |
parents | 4ea2df449381 |
children | 416fd026d76d |
comparison
equal
deleted
inserted
replaced
34:f78ffe7ce43d | 35:a8ceaa3005fd |
---|---|
10 #include "screen.h" | 10 #include "screen.h" |
11 #include "utils.h" | 11 #include "utils.h" |
12 #include "buddies.h" | 12 #include "buddies.h" |
13 #include "parsecfg.h" | 13 #include "parsecfg.h" |
14 #include "lang.h" | 14 #include "lang.h" |
15 #include "server.h" | |
16 #include "list.h" | 15 #include "list.h" |
17 | 16 |
18 #define window_entry(n) list_entry(n, window_entry_t, list) | 17 #define window_entry(n) list_entry(n, window_entry_t, list) |
19 | 18 |
20 LIST_HEAD(window_list); | 19 LIST_HEAD(window_list); |
454 void scr_InitCurses(void) | 453 void scr_InitCurses(void) |
455 { | 454 { |
456 initscr(); | 455 initscr(); |
457 noecho(); | 456 noecho(); |
458 raw(); | 457 raw(); |
459 //cbreak(); | 458 halfdelay(5); |
460 start_color(); | 459 start_color(); |
461 use_default_colors(); | 460 use_default_colors(); |
462 | 461 |
463 ParseColors(); | 462 ParseColors(); |
464 | 463 |
465 getmaxyx(stdscr, maxY, maxX); | 464 getmaxyx(stdscr, maxY, maxX); |
466 inputLine[0] = 0; | 465 inputLine[0] = 0; |
467 ptr_inputline = inputLine; | 466 ptr_inputline = inputLine; |
468 | 467 |
469 //setlocale(LC_CTYPE, ""); | 468 setlocale(LC_CTYPE, ""); |
470 | 469 |
471 return; | 470 return; |
472 } | 471 } |
473 | 472 |
474 void scr_DrawMainWindow(void) | 473 void scr_DrawMainWindow(void) |
498 //logWnd = newwin(LOG_WIN_HEIGHT - 2, maxX-20 - 2, CHAT_WIN_HEIGHT+1, 20+1); | 497 //logWnd = newwin(LOG_WIN_HEIGHT - 2, maxX-20 - 2, CHAT_WIN_HEIGHT+1, 20+1); |
499 logWnd = derwin(logWnd_border, LOG_WIN_HEIGHT-2, maxX-2, 1, 1); | 498 logWnd = derwin(logWnd_border, LOG_WIN_HEIGHT-2, maxX-2, 1, 1); |
500 logPanel = new_panel(logWnd); | 499 logPanel = new_panel(logWnd); |
501 wbkgd(logWnd, COLOR_PAIR(COLOR_GENERAL)); | 500 wbkgd(logWnd, COLOR_PAIR(COLOR_GENERAL)); |
502 //wattrset(logWnd, COLOR_PAIR(COLOR_GENERAL)); | 501 //wattrset(logWnd, COLOR_PAIR(COLOR_GENERAL)); |
503 scr_LogPrint("Start up."); | |
504 | 502 |
505 scrollok(logWnd,TRUE); | 503 scrollok(logWnd,TRUE); |
506 //idlok(logWnd,TRUE); // XXX Necessary? | 504 //idlok(logWnd,TRUE); // XXX Necessary? |
507 | 505 |
508 inputWnd = newwin(1, maxX, maxY-1, 0); | 506 inputWnd = newwin(1, maxX, maxY-1, 0); |
527 { | 525 { |
528 char **submsgs; | 526 char **submsgs; |
529 int n, i; | 527 int n, i; |
530 char *buffer = (char *) malloc(5 + strlen(text)); | 528 char *buffer = (char *) malloc(5 + strlen(text)); |
531 | 529 |
532 sprintf(buffer, "<== %s", text); | 530 sprintf(buffer, "<== %s", utf8_decode(text)); |
533 | 531 |
534 submsgs = | 532 submsgs = |
535 ut_SplitMessage(buffer, &n, maxX - scr_WindowHeight(rosterWnd) - 20); | 533 ut_SplitMessage(buffer, &n, maxX - scr_WindowHeight(rosterWnd) - 20); |
536 | 534 |
537 for (i = 0; i < n; i++) { | 535 for (i = 0; i < n; i++) { |
640 | 638 |
641 //move(CHAT_WIN_HEIGHT - 1, maxX - 1); | 639 //move(CHAT_WIN_HEIGHT - 1, maxX - 1); |
642 refresh(); | 640 refresh(); |
643 sprintf(buffer2, "%s@%s/%s", cfg_read("username"), | 641 sprintf(buffer2, "%s@%s/%s", cfg_read("username"), |
644 cfg_read("server"), cfg_read("resource")); | 642 cfg_read("server"), cfg_read("resource")); |
645 // FIXME srv_sendtext(sock, tmp->jid, msg, buffer2); | 643 jb_send_msg(tmp->jid, utf8_encode(msg)); |
646 free(buffer); | 644 free(buffer); |
647 free(buffer2); | 645 free(buffer2); |
648 | 646 |
649 top_panel(inputPanel); | 647 top_panel(inputPanel); |
650 } | 648 } |
651 | 649 |
652 int process_line(char *line) | 650 int process_line(char *line) |
653 { | 651 { |
654 if (*line != '/') { | 652 if (*line != '/') { |
655 // FIXME send_message(sock, line); | 653 send_message(line); |
656 return 0; | 654 return 0; |
657 } | 655 } |
658 if (!strcasecmp(line, "/quit")) { | 656 if (!strcasecmp(line, "/quit")) { |
659 return 255; | 657 return 255; |
660 } | 658 } |
661 // Commands handling | 659 // Commands handling |
662 // TODO | 660 // TODO |
663 // say... | 661 // say, send_raw... |
664 | 662 |
665 scr_LogPrint("Unrecognised command, sorry."); | 663 scr_LogPrint("Unrecognised command, sorry."); |
666 return 0; | 664 return 0; |
667 } | 665 } |
668 | 666 |