Changeset 13331 for lang/c/gtkwassr
- Timestamp:
- 06/06/08 21:25:20 (5 years ago)
- Location:
- lang/c/gtkwassr/trunk
- Files:
-
- 2 modified
-
Makefile.w32 (modified) (1 diff)
-
gtkwassr.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/c/gtkwassr/trunk/Makefile.w32
r6230 r13331 1 #CFLAGS=/MT 1 2 CFLAGS=/MT 2 3 -
lang/c/gtkwassr/trunk/gtkwassr.c
r6326 r13331 16 16 #endif 17 17 18 #define IS_EMOJI(x) (0xE001 <= code && code <= 0xF0FC) 19 20 /* 21 ((0xE001 <= code && code <= 0xE05A) || \ 22 (0xE101 <= code && code <= 0xE15A) || \ 23 (0xE201 <= code && code <= 0xE253) || \ 24 (0xE255 <= code && code <= 0xE257) || \ 25 (0xE301 <= code && code <= 0xE34D) || \ 26 (0xE401 <= code && code <= 0xE44C) || \ 27 (0xE501 <= code && code <= 0xE537)) // for softbank 28 */ 29 18 30 #ifdef _WIN32 19 31 # define DATA_DIR "data" … … 29 41 #define APP_URL "http://www.ac.cyberhome.ne.jp/~mattn/gtkwassr.xml" 30 42 #define SERVICE_NAME "wassr" 31 #define SERVICE_UPDATE_URL "http://api.wassr.jp/statuses/update.json" 43 #define SERVICE_UPDATE_STATUS_URL "http://api.wassr.jp/statuses/update.json" 44 #define SERVICE_TODO_LIST_URL "http://api.wassr.jp/todo/list.json" 45 #define SERVICE_TODO_ADD_URL "http://api.wassr.jp/todo/add.json" 32 46 #define SERVICE_SELF_STATUS_URL "http://api.wassr.jp/statuses/friends_timeline.rss" 33 47 #define SERVICE_FRIENDS_STATUS_URL "http://api.wassr.jp/statuses/friends_timeline.rss?id=%s" … … 42 56 #define XML_CONTENT(x) (x->children ? (char*)x->children->content : NULL) 43 57 58 static char utf8len_tab[256] = 59 { 60 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 61 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 62 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 63 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 64 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /*bogus*/ 65 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /*bogus*/ 66 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 67 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1, 68 }; 69 44 70 static GdkCursor* hand_cursor = NULL; 45 71 static GdkCursor* regular_cursor = NULL; … … 94 120 response_data = NULL; 95 121 response_size = 0; 122 } 123 124 static int utf_ptr2char(unsigned char* p) { 125 int len; 126 127 if (p[0] < 0x80) /* be quick for ASCII */ 128 return p[0]; 129 130 len = utf8len_tab[p[0]]; 131 if ((p[1] & 0xc0) == 0x80) 132 { 133 if (len == 2) 134 return ((p[0] & 0x1f) << 6) + (p[1] & 0x3f); 135 if ((p[2] & 0xc0) == 0x80) 136 { 137 if (len == 3) 138 return ((p[0] & 0x0f) << 12) + ((p[1] & 0x3f) << 6) 139 + (p[2] & 0x3f); 140 if ((p[3] & 0xc0) == 0x80) 141 { 142 if (len == 4) 143 return ((p[0] & 0x07) << 18) + ((p[1] & 0x3f) << 12) 144 + ((p[2] & 0x3f) << 6) + (p[3] & 0x3f); 145 if ((p[4] & 0xc0) == 0x80) 146 { 147 if (len == 5) 148 return ((p[0] & 0x03) << 24) + ((p[1] & 0x3f) << 18) 149 + ((p[2] & 0x3f) << 12) + ((p[3] & 0x3f) << 6) 150 + (p[4] & 0x3f); 151 if ((p[5] & 0xc0) == 0x80 && len == 6) 152 return ((p[0] & 0x01) << 30) + ((p[1] & 0x3f) << 24) 153 + ((p[2] & 0x3f) << 18) + ((p[3] & 0x3f) << 12) 154 + ((p[4] & 0x3f) << 6) + (p[5] & 0x3f); 155 } 156 } 157 } 158 } 159 /* Illegal value, just return the first byte */ 160 return p[0]; 96 161 } 97 162 … … 545 610 if (!status) return; 546 611 while(*ptr) { 612 int code = utf_ptr2char(ptr); 547 613 if (!strncmp(ptr, "http://", 7) || !strncmp(ptr, "ftp://", 6)) { 548 614 GtkTextTag *tag; … … 614 680 ptr = tmp; 615 681 } else 682 if (IS_EMOJI(code)) { 683 char* emoji; 684 GdkPixbuf* pixbuf; 685 if (last != ptr) 686 gtk_text_buffer_insert(buffer, iter, last, ptr-last); 687 688 emoji = g_strdup_printf("http://wassr.jp/img/pictogram/%X.gif", code); 689 pixbuf = url2pixbuf(emoji, NULL); 690 if (pixbuf) gtk_text_buffer_insert_pixbuf(buffer, iter, pixbuf); 691 g_free(emoji); 692 ptr += utf8len_tab[(unsigned char)*ptr]; 693 last = ptr; 694 } else 616 695 #ifdef USE_REPLAY_ACCESS 617 696 if (!strncmp(ptr, ">>", 2)) { … … 649 728 } else 650 729 #endif 651 ptr ++;730 ptr += utf8len_tab[(unsigned char)*ptr]; 652 731 } 653 732 if (last != ptr) … … 835 914 while(status) { 836 915 if (!strcmp("modified", (char*)status->name)) date = (char*)status->children->content; 837 if (!strcmp("description", (char*)status->name)) { 838 if (status->children) text = (char*)status->children->content; 916 if (!strcmp("title", (char*)status->name)) { 917 if (status->children) { 918 char *ptr; 919 text = (char*)status->children->content; 920 ptr = strstr(text, " : "); 921 if (ptr) text = ptr + 3; 922 } 839 923 } 840 924 if (!strcmp("author", (char*)status->name)) { … … 862 946 } 863 947 } 864 if (!strcmp("description", (char*)status->name)) desc = XML_CONTENT(status); 948 if (!strcmp("title", (char*)status->name)) { 949 char *ptr; 950 desc = XML_CONTENT(status); 951 ptr = strstr(desc, " : "); 952 if (ptr) desc = ptr + 3; 953 } 865 954 status = status->next; 866 955 } … … 1017 1106 /* making authenticate info */ 1018 1107 memset(url, 0, sizeof(url)); 1019 strncpy(url, SERVICE_UPDATE_URL, sizeof(url)-1);1020 1108 sanitized_message = sanitize_message_alloc(message); 1021 1109 if (!message) return NULL; 1022 message = sanitized_message; 1023 message = url_encode_alloc(message); 1024 free(sanitized_message); 1025 if (message) { 1026 strncat(url, "?status=", sizeof(url)-1);; 1027 strncat(url, message, sizeof(url)-1); 1028 free(message); 1029 strncat(url, "&source=", sizeof(url)-1); 1030 strncat(url, APP_NAME, sizeof(url)-1); 1110 1111 /* 1112 if (!strnicmp(message, "todo:", 5)) { 1113 if (strlen(message + 5) == 0) { 1114 strncpy(url, SERVICE_TODO_LIST_URL, sizeof(url)-1); 1115 } else { 1116 strncpy(url, SERVICE_TODO_ADD_URL, sizeof(url)-1); 1117 } 1118 message = sanitized_message + 5; 1119 message = url_encode_alloc(message); 1120 free(sanitized_message); 1121 if (message) { 1122 strncat(url, "?body=", sizeof(url)-1);; 1123 strncat(url, message, sizeof(url)-1); 1124 strncat(url, "&source=", sizeof(url)-1); 1125 strncat(url, APP_NAME, sizeof(url)-1); 1126 free(message); 1127 } 1128 } else 1129 */ 1130 { 1131 message = sanitized_message; 1132 message = url_encode_alloc(message); 1133 free(sanitized_message); 1134 if (message) { 1135 strncpy(url, SERVICE_UPDATE_STATUS_URL, sizeof(url)-1); 1136 strncat(url, "?status=", sizeof(url)-1);; 1137 strncat(url, message, sizeof(url)-1); 1138 strncat(url, "&source=", sizeof(url)-1); 1139 strncat(url, APP_NAME, sizeof(url)-1); 1140 free(message); 1141 } 1031 1142 } 1032 1143 memset(auth, 0, sizeof(auth));
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)