diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2019-09-01 00:00:32 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2019-09-01 00:00:32 +0200 |
commit | ca9627e70852f6b2e835660df870fe3ab405882d (patch) | |
tree | 0a008b1d5b16fa0679a195ed7b5662c7891f591c /app-dicts/libtranslate | |
download | darklin4-ca9627e70852f6b2e835660df870fe3ab405882d.tar.gz darklin4-ca9627e70852f6b2e835660df870fe3ab405882d.tar.bz2 darklin4-ca9627e70852f6b2e835660df870fe3ab405882d.tar.xz darklin4-ca9627e70852f6b2e835660df870fe3ab405882d.zip |
Initial import
Diffstat (limited to 'app-dicts/libtranslate')
-rw-r--r-- | app-dicts/libtranslate/Manifest | 13 | ||||
-rw-r--r-- | app-dicts/libtranslate/files/libtranslate-0.99-charsetparse.diff | 47 | ||||
-rw-r--r-- | app-dicts/libtranslate/files/libtranslate-0.99-condfix.diff | 38 | ||||
-rw-r--r-- | app-dicts/libtranslate/files/libtranslate-ds-empty.patch | 17 | ||||
-rw-r--r-- | app-dicts/libtranslate/files/libtranslate-ds-fixcharset.patch | 93 | ||||
-rw-r--r-- | app-dicts/libtranslate/files/libtranslate-ds-memory.patch | 12 | ||||
-rw-r--r-- | app-dicts/libtranslate/files/libtranslate-ds-promt.patch | 27 | ||||
-rw-r--r-- | app-dicts/libtranslate/files/libtranslate-ds-timed.patch.bz2 | bin | 0 -> 2863 bytes | |||
-rw-r--r-- | app-dicts/libtranslate/files/libtranslate-ds-timed24.patch | 360 | ||||
-rw-r--r-- | app-dicts/libtranslate/files/libtranslate-soup24inc.patch | 533 | ||||
-rw-r--r-- | app-dicts/libtranslate/files/services.xml | 258 | ||||
-rw-r--r-- | app-dicts/libtranslate/libtranslate-0.99-r4.ebuild | 45 | ||||
-rw-r--r-- | app-dicts/libtranslate/libtranslate-0.99-r6.ebuild | 58 |
13 files changed, 1501 insertions, 0 deletions
diff --git a/app-dicts/libtranslate/Manifest b/app-dicts/libtranslate/Manifest new file mode 100644 index 0000000..4aea792 --- /dev/null +++ b/app-dicts/libtranslate/Manifest @@ -0,0 +1,13 @@ +AUX libtranslate-0.99-charsetparse.diff 1361 SHA256 5b34c339b6c96a4b644d5ebf74ad648413b93f736ed99443b0ec3268e2b4ec27 SHA512 6bf018cb971a4bc990439fd81fb42d737e41239836cac20b1ff55b745a223e173973d630fe76021284cdecd354d11cf1e1c40c09d4af61495ecdca0f32d9df5e WHIRLPOOL 558d53a1a6b5edf3a731efd7511a8333950a329c86c32cc070125ed2048b20216d0adcf88215d984c9463e40ced25b95cee2b32cf9b5186b158c2dfa814027c7 +AUX libtranslate-0.99-condfix.diff 900 SHA256 9470ae97322c5f44b0062c8be3a7a3bb709d98a8a0e01d6d6955851a94506137 SHA512 89b846623ee72ab3d4d8ee91d777fb52a2f6a0baf9d263e5c8cc9bf931a8db3148b853b9a0ee668f72add2a3a5e77a5433ffb21934b1b256d5b855af6a76bf27 WHIRLPOOL 97529a4e9f63b6476bd5ac5d7fcff23fc4d18246c592dfa108a2707ffab6df7ef908f7d6f7854df646f0eb94b271fa5a5dfb714067a5761ac44d6fb23c23d1a5 +AUX libtranslate-ds-empty.patch 630 SHA256 37f2809ec0ac0212ef0bae48f3fad2a59a1a5c9ae2f9f63131abe49d583b21c7 SHA512 b8f4572050e0174a46adc9811ba3f8b0f613ac847e1dd9b35d8167697e2b83c4edd631c5c91ba8639237a028fd2dee49036fc6f6d2ad24ff7b623badbbb2c539 WHIRLPOOL 71a4a2330cd9d985e3f868b3fc7d6c7c2d4777dd43f5aa1cd586fabead88f2424ea7998a961649b9d7cf3ea6b245a30ed94a2a9ea7934dfa62d2295078ace0de +AUX libtranslate-ds-fixcharset.patch 3617 SHA256 4869c65e9760c7485f85955744563f19f9ae2cd4d79e9fd069563b9416694820 SHA512 cb39242e79669c3e4292ad5f333730779c20997deafa9f6fb209d281be12806a2e7848a87b8e5f8438e33dd210227c0d4ab28d8b4116987c1ab0c57d708eb02f WHIRLPOOL 559d31322741b11e8140b8f6bf2159c951913e74ff4599465d52cc2cdf55f9ee5d5bac81eb50ef9e7ee4aed6f194d4934ae4fd2a8279ac35049be29c47bb689c +AUX libtranslate-ds-memory.patch 555 SHA256 5ccd7841a3fbbe51703611d453ce9791075b452459b601f6fff7b3e123461895 SHA512 b3f9acf38ba8a2ebbc3c9179981049db748b697cb5b8d3c2eb745b746642eedfe0d8fc32f90a35f93b143da310efc406c289613387365c63c5e92185e2fdd8d0 WHIRLPOOL ae2f5eaf3e1663a16484f3e8341f9b3cea304365dba349ae95768215c3a4b89a5b0d71b5e930e4470d9d79e941c9ec2f20c0fc20e90804f945d37babbe9c6cb4 +AUX libtranslate-ds-promt.patch 994 SHA256 ebbefe92cecdae7164429121979dcf18aec33cbb3d749f2e5b6bbc1236533ea7 SHA512 fbba665748580c5e26488c7e28fd48f488c2e1e07243186ff801202ab89701235dcdec9a24a24ad53d19b82293e4b925ff0fa07e0ef138ef5bf5b4f8ff73d2cc WHIRLPOOL c44555e82d77056769ca091d4cb7347622232cbdbf8d75f9450d90c5dc0e5a6c734d5c54b2a143bc1cfe14c7a3c00bd485726e9d89bb99ad3b48eed1346b95cd +AUX libtranslate-ds-timed.patch.bz2 2863 SHA256 3ff5e50c86d70f7bf47e47793b7231828792e63e4a79a70fae89de84129be9bf SHA512 040cf50f8c31161d8a4395b4a9cf8c4723a84f16b63ede6b50df92a265d1e3845dea42522461373343c6f18e4cf0f38ce4cc9bc90873e6c65ed4846dd7b8bf41 WHIRLPOOL 722f46cb153cc8072e57c319274f4d4e3e0f57e9155244160b774ad7aaebcb53cd071a234556c53d42609d425bbc512d5edbfef479be5c71587d52eddaf252a6 +AUX libtranslate-ds-timed24.patch 12354 SHA256 25a724496f2a76b5cce1696539aed1ff7ba026c816004b27fcc42c69585bd864 SHA512 b75a001bd7ef7da6f55fc79865741411ca5423d170ff7412bc40de1967e7692c6bdb9e7b69b6c3a82066b5250260ba379b604c349a0635ba88a2b107c42b0e6a WHIRLPOOL 0ec93e96b8b9cd9a99bf6347fd280734b8e9488215f3236af4712ad75b7b80bb4c30020e0b6c49aa0e4462ed26c7a6445a1f1d6a74524bab103f3dcaf5f69342 +AUX libtranslate-soup24inc.patch 18404 SHA256 7a9f4680bf3163bb924c018a8eb98327714f37f9615f76cfaa885d2a28d829a0 SHA512 2f92b7a4263773976763c505fd52669e84669a4785eaf1d43d33a205a56c202bea7425629b6d4c9b9401332268548f721ecefd530d1c316dc97eaca7eb992d8f WHIRLPOOL 2ef354ac5453fdcbfc505e59debc1af546ea87ce78deadf1308b44ab9f6ea15211339706148ec9e9a1de66ea7ee0181a27c4329ef09f3885c66f850f1f8deeae +AUX services.xml 10535 SHA256 1663e83f736fa7e710e82f218e7c3203fd102791c7318e49088724b42bcb9f8f SHA512 f77dab2fffc03a4a024859ab960d88d474648a1c20df7bada58f01c7b594ec987b669fd8b3575a8b2118c0a6ddc55fc69027a2ab743eb1ba99d0a52f4b3b9205 WHIRLPOOL c0d833075f3a8c455ad8c6231474fa482bd01222874256a8fde7fe9cee6738a9fa4856f1c2645a61b4b9cce99ec4aa753fe1e0d3b215b54d139c5d1ef36b82f1 +DIST libtranslate-0.99.tar.gz 532516 SHA256 4b2becb139e51663022d9531c430ebcc81d8b26edc73f6ddc05707ff9950eb34 SHA512 e8951224a09aedd83bf82d38b6808d7395f8e377982544f26e26ded9fe30fa11b1ac4df3442694f15d5f1a61dcb3a4da8ba7fd6871e17920a01c9758b3ecfc9d WHIRLPOOL b48fe9bf4aee18334b8e2518a63bb5f9bc9412223872692987828c3d46639d7a35ddb36655ec787a40ae918453fbe66521cfa72c7d77e88ed2749c16a5c8c0fb +EBUILD libtranslate-0.99-r4.ebuild 1134 SHA256 002fab38d01ea2722f398f473cb09ba481eb19e26a462ebd1bff9ba5bc49d3ee SHA512 430f4de80bf1b37d4eeef3e637b271e53a99033003f8fa408da7d4d262af5485b9ccc01df0a8be545e111986f0b121a812c68c04336c5cf1c28f50a96d4d624b WHIRLPOOL c5af0a095552a1112dc1ff471f15dc8cadc178985934adfda35d4d6ee9426e68fe6ee2cbbce9e0662dedd6cdb71592a89504f9de6dea5cbc8c99a00331bdee7a +EBUILD libtranslate-0.99-r6.ebuild 1462 SHA256 2a5eb04a46e1c57c661ef26229dc77113581ddd0482249609db3af9abfef46c1 SHA512 e47a9ad562103c8e9f9570473b0928a5197d70c75cb7fe8ae11cbde686b58aa6da1e711f1c8621814e48f46e41dc0be45defb2253c3510420a2d2922cdd27e61 WHIRLPOOL 0a9d9054fdc191f507190f96c2ced75a975a0eee46bf79875fdb88b8fd770e2bb5b4ab3784f330f2cdeb8b84b39a39c6b22e30339ef7feb6fc7857ae75d34a1a diff --git a/app-dicts/libtranslate/files/libtranslate-0.99-charsetparse.diff b/app-dicts/libtranslate/files/libtranslate-0.99-charsetparse.diff new file mode 100644 index 0000000..1626f25 --- /dev/null +++ b/app-dicts/libtranslate/files/libtranslate-0.99-charsetparse.diff @@ -0,0 +1,47 @@ +--- src/modules/translate-generic-service.c.orig Mon Apr 11 23:08:47 2005 ++++ src/modules/translate-generic-service.c Mon Apr 11 23:15:54 2005 +@@ -484,7 +484,7 @@ + + if (SOUP_STATUS_IS_SUCCESSFUL(message->status_code)) + { +- const char *charset = NULL; ++ char *charset = NULL; + + if (flags & TRANSFER_CONVERT) + { +@@ -493,14 +493,31 @@ + content_type = translate_generic_service_get_header(message, &info, "Content-Type"); + if (content_type) + { +- charset = translate_ascii_strcasestr(content_type, "charset="); +- if (charset) +- charset += 8; ++ const char *tmp; ++ ++ tmp = translate_ascii_strcasestr(content_type, "charset="); ++ if (tmp) ++ { ++ int len; ++ ++ tmp += 8; ++ if (*tmp == '\'' || *tmp == '"') ++ tmp++; ++ ++ len = strlen(tmp); ++ if (len > 0 && (tmp[len - 1] == '\'' || tmp[len - 1] == '"')) ++ len--; ++ ++ charset = g_strndup(tmp, len); ++ } + } + } + + if (charset) +- response = g_convert(message->response.body, message->response.length, "UTF-8", charset, NULL, NULL, err); ++ { ++ response = g_convert(message->response.body, message->response.length, "UTF-8", charset, NULL, NULL, err); ++ g_free(charset); ++ } + else + { + if ((flags & TRANSFER_CONVERT) && ! g_utf8_validate(message->response.body, message->response.length, NULL)) diff --git a/app-dicts/libtranslate/files/libtranslate-0.99-condfix.diff b/app-dicts/libtranslate/files/libtranslate-0.99-condfix.diff new file mode 100644 index 0000000..4011dcd --- /dev/null +++ b/app-dicts/libtranslate/files/libtranslate-0.99-condfix.diff @@ -0,0 +1,38 @@ +--- src/translate-session.c.orig Mon Apr 11 22:44:53 2005 ++++ src/translate-session.c Mon Apr 11 22:51:48 2005 +@@ -703,7 +703,14 @@ + GError *tmp_err = NULL; + + g_mutex_lock(info->mutex); +- ret = info->err != NULL; ++ if (info->err) ++ { ++ ret = TRUE; ++ if (info->progress_cond) ++ g_cond_signal(info->progress_cond); ++ } ++ else ++ ret = FALSE; + g_mutex_unlock(info->mutex); + + if (ret) +@@ -728,6 +735,9 @@ + else + g_propagate_error(&info->err, tmp_err); + ++ if (info->progress_cond) ++ g_cond_signal(info->progress_cond); ++ + g_mutex_unlock(info->mutex); + + return; +@@ -759,6 +769,9 @@ + info->err = g_error_new(TRANSLATE_SESSION_ERROR, + TRANSLATE_SESSION_ERROR_NO_SERVICE, + _("no service could translate chunk")); ++ ++ if (info->progress_cond) ++ g_cond_signal(info->progress_cond); + } + + g_mutex_unlock(info->mutex); diff --git a/app-dicts/libtranslate/files/libtranslate-ds-empty.patch b/app-dicts/libtranslate/files/libtranslate-ds-empty.patch new file mode 100644 index 0000000..eb2e0ce --- /dev/null +++ b/app-dicts/libtranslate/files/libtranslate-ds-empty.patch @@ -0,0 +1,17 @@ +diff -dPNur libtranslate-0.99/src/modules/translate-generic-service.c libtranslate-0.99-new/src/modules/translate-generic-service.c +--- libtranslate-0.99/src/modules/translate-generic-service.c 2007-06-27 17:26:10.000000000 +0200 ++++ libtranslate-0.99-new/src/modules/translate-generic-service.c 2007-06-27 17:23:55.000000000 +0200 +@@ -1042,6 +1042,13 @@ + + g_free(response); + } ++ ++ if ((!answer)&&(!*err)) { ++ g_set_error(err, ++ TRANSLATE_GENERIC_SERVICE_ERROR, ++ TRANSLATE_GENERIC_SERVICE_ERROR_PARSE, ++ _("empty server response")); ++ } + + return answer ? g_string_free(answer, FALSE) : NULL; + } diff --git a/app-dicts/libtranslate/files/libtranslate-ds-fixcharset.patch b/app-dicts/libtranslate/files/libtranslate-ds-fixcharset.patch new file mode 100644 index 0000000..0665d2f --- /dev/null +++ b/app-dicts/libtranslate/files/libtranslate-ds-fixcharset.patch @@ -0,0 +1,93 @@ +diff -dPNur libtranslate-0.99-new/src/modules/translate-generic-parser.c libtranslate-0.99-new-uk/src/modules/translate-generic-parser.c +--- libtranslate-0.99-new/src/modules/translate-generic-parser.c 2005-01-17 17:46:24.000000000 +0100 ++++ libtranslate-0.99-new-uk/src/modules/translate-generic-parser.c 2007-06-27 22:40:04.000000000 +0200 +@@ -726,6 +726,7 @@ + { + const char *url; + const char *post; ++ const char *charset; + const char *content_type; + + g_return_if_fail(info != NULL); +@@ -740,6 +741,7 @@ + "url", REQUIRED, &url, + "post", OPTIONAL, &post, + "content-type", OPTIONAL, &content_type, ++ "response-charset", OPTIONAL, &charset, + NULL); + + if (! *err) +@@ -748,6 +750,7 @@ + (*location)->url = g_strdup(url); + (*location)->post = g_strdup(post); + (*location)->content_type = g_strdup(content_type ? content_type : "application/x-www-form-urlencoded"); ++ (*location)->response_charset = g_strdup(charset); + } + } + +@@ -759,6 +762,7 @@ + g_free(location->url); + g_free(location->post); + g_free(location->content_type); ++ g_free(location->response_charset); + g_slist_foreach(location->http_headers, (GFunc) translate_generic_http_header_free, NULL); + g_slist_free(location->http_headers); + g_free(location); +diff -dPNur libtranslate-0.99-new/src/modules/translate-generic-parser.h libtranslate-0.99-new-uk/src/modules/translate-generic-parser.h +--- libtranslate-0.99-new/src/modules/translate-generic-parser.h 2005-01-17 17:46:30.000000000 +0100 ++++ libtranslate-0.99-new-uk/src/modules/translate-generic-parser.h 2007-06-27 22:34:13.000000000 +0200 +@@ -51,6 +51,7 @@ + char *url; + char *post; + char *content_type; ++ char *response_charset; + GSList *http_headers; + } TranslateGenericLocation; + +diff -dPNur libtranslate-0.99-new/src/modules/translate-generic-service.c libtranslate-0.99-new-uk/src/modules/translate-generic-service.c +--- libtranslate-0.99-new/src/modules/translate-generic-service.c 2007-06-27 17:23:55.000000000 +0200 ++++ libtranslate-0.99-new-uk/src/modules/translate-generic-service.c 2007-06-27 22:40:29.000000000 +0200 +@@ -129,6 +129,7 @@ + static char *translate_generic_service_get (const char *uri, + const char *post, + const char *post_content_type, ++ const char *response_charset, + const GSList *headers, + TransferFlags flags, + GTimeVal *deadline, +@@ -407,6 +408,7 @@ + translate_generic_service_get (const char *uri, + const char *post, + const char *post_content_type, ++ const char *response_charset, + const GSList *headers, + TransferFlags flags, + GTimeVal *deadline, +@@ -550,9 +552,9 @@ + } + } + +- if (charset) ++ if ((charset)||(response_charset)) + { +- response = g_convert(message->response.body, message->response.length, "UTF-8", charset, NULL, NULL, err); ++ response = g_convert(message->response.body, message->response.length, "UTF-8", response_charset?response_charset:charset, NULL, NULL, err); + g_free(charset); + } + else +@@ -941,6 +943,7 @@ + response = translate_generic_service_get(url, + post, + group->text_location->content_type, ++ group->text_location->response_charset, + headers, + TRANSFER_FOLLOW_REFRESH | TRANSFER_CONVERT, + deadline, +@@ -1339,6 +1342,7 @@ + response = translate_generic_service_get(translation_url, + post, + group->web_page_location->content_type, ++ group->web_page_location->response_charset, + headers, + 0, + NULL, diff --git a/app-dicts/libtranslate/files/libtranslate-ds-memory.patch b/app-dicts/libtranslate/files/libtranslate-ds-memory.patch new file mode 100644 index 0000000..e05c7b4 --- /dev/null +++ b/app-dicts/libtranslate/files/libtranslate-ds-memory.patch @@ -0,0 +1,12 @@ +diff -dPNur libtranslate-0.99/src/translate-util.c libtranslate-0.99-new/src/translate-util.c +--- libtranslate-0.99/src/translate-util.c 2005-01-17 16:45:45.000000000 +0000 ++++ libtranslate-0.99-new/src/translate-util.c 2005-12-29 18:35:04.000000000 +0000 +@@ -136,7 +136,7 @@ + g_return_val_if_fail(big != NULL, NULL); + g_return_val_if_fail(little != NULL, NULL); + +- lower_big = g_ascii_strdown(big, big_len); ++ lower_big = g_ascii_strdown(big, (int)big_len); + lower_little = g_ascii_strdown(little, -1); + + s = strstr(lower_big, lower_little); diff --git a/app-dicts/libtranslate/files/libtranslate-ds-promt.patch b/app-dicts/libtranslate/files/libtranslate-ds-promt.patch new file mode 100644 index 0000000..6b30145 --- /dev/null +++ b/app-dicts/libtranslate/files/libtranslate-ds-promt.patch @@ -0,0 +1,27 @@ +diff -dPNur libtranslate-0.99/src/modules/translate-generic-service.c libtranslate-0.99-new/src/modules/translate-generic-service.c +--- libtranslate-0.99/src/modules/translate-generic-service.c 2007-06-27 17:26:10.000000000 +0200 ++++ libtranslate-0.99-new/src/modules/translate-generic-service.c 2007-06-27 17:23:55.000000000 +0200 +@@ -1238,7 +1245,22 @@ + { + if (modifier_value) + g_warning(_("%s: value specified for \"escape\" modifier"), warning_prefix); +- modified = soup_uri_encode(value, NULL); ++ modified = soup_uri_encode(value, "&"); ++ } ++ else if (! strcmp(modifier_name, "entities")) ++ { ++ int i; ++ char *ptr; ++ ++ modified = g_malloc(strlen(value)*6 + 1); ++ for (i=0,ptr=modified;value[i];i++) { ++ if ((unsigned char)(value[i])<160) *(ptr++)=value[i]; ++ else { ++ sprintf(ptr, "&#%u;", (unsigned char)(value[i])); ++ ptr+=6; ++ } ++ } ++ *ptr = 0; + } + else if (! strcmp(modifier_name, "charset")) + { diff --git a/app-dicts/libtranslate/files/libtranslate-ds-timed.patch.bz2 b/app-dicts/libtranslate/files/libtranslate-ds-timed.patch.bz2 Binary files differnew file mode 100644 index 0000000..c5b3a86 --- /dev/null +++ b/app-dicts/libtranslate/files/libtranslate-ds-timed.patch.bz2 diff --git a/app-dicts/libtranslate/files/libtranslate-ds-timed24.patch b/app-dicts/libtranslate/files/libtranslate-ds-timed24.patch new file mode 100644 index 0000000..daf3811 --- /dev/null +++ b/app-dicts/libtranslate/files/libtranslate-ds-timed24.patch @@ -0,0 +1,360 @@ +diff -dPNur libtranslate-0.99/src/modules/translate-generic-service.c libtranslate-0.99-new/src/modules/translate-generic-service.c +--- libtranslate-0.99/src/modules/translate-generic-service.c 2005-01-17 17:46:38.000000000 +0100 ++++ libtranslate-0.99-new/src/modules/translate-generic-service.c 2005-07-27 22:13:33.000000000 +0200 +@@ -131,6 +131,7 @@ + const char *post_content_type, + const GSList *headers, + TransferFlags flags, ++ GTimeVal *deadline, + TranslateProgressFunc progress_func, + gpointer user_data, + GError **err); +@@ -181,6 +182,15 @@ + gpointer user_data, + GError **err); + ++static char *translate_generic_service_timed_translate_text (TranslateService *service, ++ const char *text, ++ const char *from, ++ const char *to, ++ GTimeVal *deadline, ++ TranslateProgressFunc progress_func, ++ gpointer user_data, ++ GError **err); ++ + char *translate_generic_service_expand (const char *warning_prefix, + const char *str, + ...); +@@ -248,6 +258,7 @@ + + service_class->get_pairs = translate_generic_service_get_pairs; + service_class->translate_text = translate_generic_service_translate_text; ++ service_class->timed_translate_text = translate_generic_service_timed_translate_text; + service_class->translate_web_page = translate_generic_service_translate_web_page; + + g_object_class_install_property(object_class, +@@ -387,12 +398,22 @@ + return TRUE; /* continue */ + } + ++#ifdef HAVE_LIBSOUP22 ++static void send_message_cb(SoupMessage *req, gpointer user_data) { ++#else ++static void send_message_cb(SoupSession *session, SoupMessage *req, gpointer user_data) { ++#endif ++ g_object_ref(req); ++ *(gboolean*)user_data = TRUE; ++} ++ + static char * + translate_generic_service_get (const char *uri, + const char *post, + const char *post_content_type, + const GSList *headers, + TransferFlags flags, ++ GTimeVal *deadline, + TranslateProgressFunc progress_func, + gpointer user_data, + GError **err) +@@ -400,6 +417,8 @@ + TransferInfo info; + SoupMessage *message; + const GSList *l; ++ GTimeVal tv; ++ gboolean completed = 0, canceled = 0; + char *response = NULL; + + g_return_val_if_fail(uri != NULL, FALSE); +@@ -479,9 +498,31 @@ + if (translate_generic_debug_flags & TRANSLATE_GENERIC_DEBUG_LOG_TRANSFERS) + translate_generic_service_log_connect(message); + ++ if (deadline) { ++ soup_session_queue_message(info.session, message, send_message_cb, &completed); ++ ++ do { ++ g_main_iteration (FALSE); ++ if (completed) break; ++ ++ g_get_current_time(&tv); ++ } while ((tv.tv_sec < deadline->tv_sec)||((tv.tv_sec == deadline->tv_sec)&&(tv.tv_usec < deadline->tv_usec))); ++ ++ if (!completed) { ++#ifdef HAVE_LIBSOUP22 ++ soup_session_cancel_message(info.session, message); ++#else ++ soup_session_cancel_message(info.session, message, SOUP_STATUS_CANCELLED); ++#endif ++ canceled = 1; ++ } ++ } else + soup_session_send_message(info.session, message); + g_object_unref(info.session); + ++ if (canceled) ++ g_set_error(err, TRANSLATE_ERROR, TRANSLATE_ERROR_CANCELLED, _("Timeout")); ++ else + if (SOUP_STATUS_IS_SUCCESSFUL(message->status_code)) + { + const char *charset = NULL; +@@ -833,10 +870,11 @@ + } + + static char * +-translate_generic_service_translate_text (TranslateService *service, ++translate_generic_service_timed_translate_text (TranslateService *service, + const char *text, + const char *from, + const char *to, ++ GTimeVal *deadline, + TranslateProgressFunc progress_func, + gpointer user_data, + GError **err) +@@ -882,16 +920,16 @@ + + headers = g_slist_copy(group->http_headers); + headers = g_slist_concat(headers, g_slist_copy(group->text_location->http_headers)); +- ++ + response = translate_generic_service_get(url, + post, + group->text_location->content_type, + headers, + TRANSFER_FOLLOW_REFRESH | TRANSFER_CONVERT, ++ deadline, + progress_func, + user_data, + err); +- + g_free(url); + g_free(post); + g_slist_free(headers); +@@ -991,6 +1029,18 @@ + return answer ? g_string_free(answer, FALSE) : NULL; + } + ++static char * ++translate_generic_service_translate_text (TranslateService *service, ++ const char *text, ++ const char *from, ++ const char *to, ++ TranslateProgressFunc progress_func, ++ gpointer user_data, ++ GError **err) ++{ ++ return translate_generic_service_timed_translate_text(service, text, from, to, NULL, progress_func, user_data, err); ++} ++ + char * + translate_generic_service_expand (const char *warning_prefix, + const char *str, +@@ -1252,6 +1302,7 @@ + group->web_page_location->content_type, + headers, + 0, ++ NULL, + progress_func, + user_data, + err); +@@ -1311,7 +1362,7 @@ + g_free(proxy_text_uri); + } + +- session = soup_session_sync_new_with_options(SOUP_SESSION_PROXY_URI, proxy_uri, NULL); ++ session = soup_session_async_new_with_options(SOUP_SESSION_PROXY_URI, proxy_uri, NULL); + + if (proxy_uri) + soup_uri_free(proxy_uri); +diff -dPNur libtranslate-0.99/src/translate-service.c libtranslate-0.99-new/src/translate-service.c +--- libtranslate-0.99/src/translate-service.c 2005-01-17 17:45:23.000000000 +0100 ++++ libtranslate-0.99-new/src/translate-service.c 2005-07-27 17:18:07.000000000 +0200 +@@ -372,6 +372,28 @@ + } + + char * ++translate_service_timed_translate_text (TranslateService *service, ++ const char *text, ++ const char *from, ++ const char *to, ++ GTimeVal *deadline, ++ TranslateProgressFunc progress_func, ++ gpointer user_data, ++ GError **err) ++{ ++ g_return_val_if_fail(TRANSLATE_IS_SERVICE(service), NULL); ++ g_return_val_if_fail(TRANSLATE_SERVICE_GET_CLASS(service)->translate_text != NULL, NULL); ++ g_return_val_if_fail(text != NULL, NULL); ++ g_return_val_if_fail(from != NULL, NULL); ++ g_return_val_if_fail(to != NULL, NULL); ++ ++ if (TRANSLATE_SERVICE_GET_CLASS(service)->timed_translate_text) ++ return TRANSLATE_SERVICE_GET_CLASS(service)->timed_translate_text(service, text, from, to, deadline, progress_func, user_data, err); ++ ++ return TRANSLATE_SERVICE_GET_CLASS(service)->translate_text(service, text, from, to, progress_func, user_data, err); ++} ++ ++char * + translate_service_translate_web_page (TranslateService *service, + const char *url, + const char *from, +diff -dPNur libtranslate-0.99/src/translate-service.h libtranslate-0.99-new/src/translate-service.h +--- libtranslate-0.99/src/translate-service.h 2005-01-17 17:45:29.000000000 +0100 ++++ libtranslate-0.99-new/src/translate-service.h 2005-07-27 16:54:46.000000000 +0200 +@@ -73,6 +73,14 @@ + TranslateProgressFunc progress_func, + gpointer user_data, + GError **err); ++ char *(*timed_translate_text)(TranslateService *service, ++ const char *text, ++ const char *from, ++ const char *to, ++ GTimeVal *deadline, ++ TranslateProgressFunc progress_func, ++ gpointer user_data, ++ GError **err); + char *(*translate_web_page) (TranslateService *service, + const char *url, + const char *from, +diff -dPNur libtranslate-0.99/src/translate-service-private.h libtranslate-0.99-new/src/translate-service-private.h +--- libtranslate-0.99/src/translate-service-private.h 2005-01-17 17:45:17.000000000 +0100 ++++ libtranslate-0.99-new/src/translate-service-private.h 2005-07-27 17:30:00.000000000 +0200 +@@ -41,6 +41,14 @@ + TranslateProgressFunc progress_func, + gpointer user_data, + GError **err); ++char *translate_service_timed_translate_text (TranslateService *service, ++ const char *text, ++ const char *from, ++ const char *to, ++ GTimeVal *deadline, ++ TranslateProgressFunc progress_func, ++ gpointer user_data, ++ GError **err); + char *translate_service_translate_web_page (TranslateService *service, + const char *url, + const char *from, +diff -dPNur libtranslate-0.99/src/translate-session.c libtranslate-0.99-new/src/translate-session.c +--- libtranslate-0.99/src/translate-session.c 2005-01-17 17:45:35.000000000 +0100 ++++ libtranslate-0.99-new/src/translate-session.c 2005-07-27 16:52:46.000000000 +0200 +@@ -62,6 +62,8 @@ + { + GMutex *mutex; + GCond *progress_cond; ++ ++ GTimeVal *deadline; + + TranslateSession *session; + GSList *services; +@@ -487,6 +489,7 @@ + * @text: a nul-terminated string. + * @from: a RFC 3066 language tag. + * @to: a RFC 3066 language tag. ++ * @timeout: timeout in microseconds. + * @progress_func: a function to call when progressing, or %NULL. + * @user_data: data to pass to @progress_func, or %NULL. + * @err: a location to report errors, or %NULL. Any of the errors in +@@ -505,10 +508,11 @@ + * when no longer needed. + **/ + char * +-translate_session_translate_text (TranslateSession *session, ++translate_session_timed_translate_text (TranslateSession *session, + const char *text, + const char *from, + const char *to, ++ gulong timeout, + TranslateProgressFunc progress_func, + gpointer user_data, + GError **err) +@@ -519,6 +523,7 @@ + unsigned int max_threads; + GThreadPool *pool; + GSList *l; ++ GTimeVal deadline; + unsigned int max_chunk_len = 0; + char *translated = NULL; + +@@ -527,6 +532,11 @@ + g_return_val_if_fail(from != NULL, NULL); + g_return_val_if_fail(to != NULL, NULL); + ++ if (timeout) { ++ g_get_current_time(&deadline); ++ g_time_val_add(&deadline, timeout); ++ } ++ + LOCK(session); + info.services = translate_session_get_services_for_translation(session, + TRANSLATE_PAIR_TEXT, +@@ -560,7 +570,8 @@ + chunks = translate_session_split(text, max_chunk_len); + + info.mutex = g_mutex_new(); +- info.progress_cond = progress_func ? g_cond_new() : NULL; ++ info.progress_cond = (progress_func||timeout) ? g_cond_new() : NULL; ++ info.deadline = timeout ? &deadline : NULL; + info.session = session; + info.chunks = NULL; + info.from = from; +@@ -614,6 +625,11 @@ + GSList *l; + int n_chunks; + ++ if (timeout) { ++ if (!g_cond_timed_wait(info.progress_cond, info.mutex, info.deadline)) ++ info.err = g_error_new(TRANSLATE_ERROR,TRANSLATE_ERROR_CANCELLED,_("timeout")); ++ break; ++ } else + g_cond_wait(info.progress_cond, info.mutex); + + if (info.err) +@@ -680,6 +696,18 @@ + return translated; + } + ++char * ++translate_session_translate_text (TranslateSession *session, ++ const char *text, ++ const char *from, ++ const char *to, ++ TranslateProgressFunc progress_func, ++ gpointer user_data, ++ GError **err) ++{ ++ return translate_session_timed_translate_text(session, text, from, to, 0, progress_func, user_data, err); ++} ++ + static void + translate_session_translate_thread (gpointer data, gpointer user_data) + { +@@ -709,10 +737,11 @@ + if (ret) + return; + +- chunk_info->translated = translate_service_translate_text(service, ++ chunk_info->translated = translate_service_timed_translate_text(service, + chunk_info->chunk, + info->from, + info->to, ++ info->deadline, + info->progress_cond ? translate_session_translate_progress_cb : NULL, + info->progress_cond ? chunk_info : NULL, + &tmp_err); +diff -dPNur libtranslate-0.99/src/translate-session.h libtranslate-0.99-new/src/translate-session.h +--- libtranslate-0.99/src/translate-session.h 2005-01-17 17:45:40.000000000 +0100 ++++ libtranslate-0.99-new/src/translate-session.h 2005-07-27 14:41:05.000000000 +0200 +@@ -93,6 +93,14 @@ + unsigned int translate_session_get_max_threads (TranslateSession *session); + int translate_session_get_max_retries (TranslateSession *session); + ++char *translate_session_timed_translate_text (TranslateSession *session, ++ const char *text, ++ const char *from, ++ const char *to, ++ gulong timeout, ++ TranslateProgressFunc progress_func, ++ gpointer user_data, ++ GError **err); + char *translate_session_translate_text (TranslateSession *session, + const char *text, + const char *from, diff --git a/app-dicts/libtranslate/files/libtranslate-soup24inc.patch b/app-dicts/libtranslate/files/libtranslate-soup24inc.patch new file mode 100644 index 0000000..8de7c07 --- /dev/null +++ b/app-dicts/libtranslate/files/libtranslate-soup24inc.patch @@ -0,0 +1,533 @@ +diff -dPNur libtranslate-0.99/config.h.in libtranslate-0.99-1/config.h.in +--- libtranslate-0.99/config.h.in 2005-01-17 18:06:58.000000000 +0100 ++++ libtranslate-0.99-1/config.h.in 2010-02-14 03:55:56.000000000 +0100 +@@ -24,6 +24,12 @@ + /* Define if your <locale.h> file defines LC_MESSAGES. */ + #undef HAVE_LC_MESSAGES + ++/* Building with libsoup 2.2 */ ++#undef HAVE_LIBSOUP22 ++ ++/* Building with libsoup 2.4 */ ++#undef HAVE_LIBSOUP24 ++ + /* Define to 1 if you have the <locale.h> header file. */ + #undef HAVE_LOCALE_H + +diff -dPNur libtranslate-0.99/configure.ac libtranslate-0.99-1/configure.ac +--- libtranslate-0.99/configure.ac 2005-01-15 17:24:12.000000000 +0100 ++++ libtranslate-0.99-1/configure.ac 2010-02-14 03:55:56.000000000 +0100 +@@ -50,7 +50,11 @@ + ### optional libraries + + if TRANSLATE_FEATURE_ENABLED(generic); then +- PKG_CHECK_MODULES(SOUP, [libsoup-2.2],, [TRANSLATE_FEATURE_DISABLE(generic, [libsoup not found])]) ++ PKG_CHECK_MODULES(SOUP, [libsoup-2.4], ++ [AC_DEFINE(HAVE_LIBSOUP24, 1, [Building with libsoup 2.4])], ++ [PKG_CHECK_MODULES(SOUP, [libsoup-2.2], ++ [AC_DEFINE(HAVE_LIBSOUP22, 1, [Building with libsoup 2.2])], ++ [TRANSLATE_FEATURE_DISABLE(generic, [libsoup not found])])]) + fi + if TRANSLATE_FEATURE_ENABLED(generic); then + PKG_CHECK_MODULES(LIBXML, [libxml-2.0],, [TRANSLATE_FEATURE_DISABLE(generic, [libxml not found])]) +diff -dPNur libtranslate-0.99/src/modules/translate-generic-service.c libtranslate-0.99-1/src/modules/translate-generic-service.c +--- libtranslate-0.99/src/modules/translate-generic-service.c 2010-02-14 03:55:34.000000000 +0100 ++++ libtranslate-0.99-1/src/modules/translate-generic-service.c 2010-02-14 04:04:56.000000000 +0100 +@@ -35,7 +35,9 @@ + #include <stdlib.h> + #include <glib/gi18n-lib.h> + #include <libsoup/soup.h> ++#ifdef HAVE_LIBSOUP22 + #include <libsoup/soup-message-filter.h> ++#endif + #include <libxml/HTMLparser.h> + #include "translate.h" + #include "translate-generic-service.h" +@@ -43,6 +45,17 @@ + #include "translate-generic-parser.h" + #include "translate-generic-soup-cookie-jar.h" + ++#ifdef HAVE_LIBSOUP22 ++#define soup_message_headers_get soup_message_get_header ++#define soup_message_headers_append soup_message_add_header ++#define SoupURI SoupUri ++#define SOUP_MESSAGE_RESPONSE_BODY(msg) ((msg)->response.body) ++#define SOUP_MESSAGE_RESPONSE_LENGTH(msg) ((msg)->response.length) ++#else ++#define SOUP_MESSAGE_RESPONSE_BODY(msg) ((msg)->response_body->data) ++#define SOUP_MESSAGE_RESPONSE_LENGTH(msg) ((msg)->response_body->length) ++#endif ++ + #define MAKE_WARNING_PREFIX(service, group_pos, attribute, element) \ + g_strdup_printf(_("in %s, group %i, \"%s\" attribute of \"%s\" element"), \ + translate_service_get_name((service)), \ +@@ -142,6 +155,7 @@ + const char *name); + + static void translate_generic_service_log_connect (SoupMessage *message); ++#ifdef HAVE_LIBSOUP22 + static void translate_generic_service_log_wrote_headers_h (SoupMessage *message, + gpointer user_data); + static void translate_generic_service_log_wrote_body_h (SoupMessage *message, +@@ -153,10 +167,20 @@ + static void translate_generic_service_log_headers_cb (const char *key, + const char *value, + gpointer user_data); ++#else ++static void translate_generic_service_log_printer (SoupLogger *logger, ++ SoupLoggerLogLevel level, ++ char direction, ++ const char *data, ++ gpointer user_data); ++#endif + + static void translate_generic_service_progress_got_headers_h (SoupMessage *message, + gpointer user_data); + static void translate_generic_service_progress_got_chunk_h (SoupMessage *message, ++#ifdef HAVE_LIBSOUP24 ++ SoupBuffer *chunk, ++#endif + gpointer user_data); + + static void translate_generic_service_html_got_headers_h (SoupMessage *message, +@@ -172,8 +196,10 @@ + static void translate_generic_service_refresh_got_body_h (SoupMessage *message, + gpointer user_data); + ++#ifdef HAVE_LIBSOUP22 + static void translate_generic_service_redirect_handler (SoupMessage *message, + gpointer user_data); ++#endif + + static char *translate_generic_service_translate_text (TranslateService *service, + const char *text, +@@ -440,7 +466,11 @@ + g_return_val_if_fail(post_content_type != NULL, NULL); + soup_message_set_request(message, + post_content_type, ++#ifdef HAVE_LIBSOUP22 + SOUP_BUFFER_USER_OWNED, ++#else ++ SOUP_MEMORY_TEMPORARY, ++#endif + (char *) post, + strlen(post)); + } +@@ -448,7 +478,7 @@ + for (l = headers; l != NULL; l = l->next) + { + TranslateGenericHttpHeader *header = l->data; +- soup_message_add_header(message->request_headers, header->name, header->value); ++ soup_message_headers_append(message->request_headers, header->name, header->value); + } + + info.session = translate_generic_service_soup_session_sync_new(); +@@ -456,12 +486,21 @@ + info.html_http_equiv = NULL; + + if (translate_generic_debug_flags & TRANSLATE_GENERIC_DEBUG_LOG_TRANSFERS) +- g_object_connect(message, +- "signal::wrote-headers", translate_generic_service_log_wrote_headers_h, &info, +- "signal::wrote-body", translate_generic_service_log_wrote_body_h, &info, +- "signal::got-headers", translate_generic_service_log_got_headers_h, &info, +- "signal::got-body", translate_generic_service_log_got_body_h, &info, +- NULL); ++ { ++#ifdef HAVE_LIBSOUP22 ++ g_object_connect(message, ++ "signal::wrote-headers", translate_generic_service_log_wrote_headers_h, &info, ++ "signal::wrote-body", translate_generic_service_log_wrote_body_h, &info, ++ "signal::got-headers", translate_generic_service_log_got_headers_h, &info, ++ "signal::got-body", translate_generic_service_log_got_body_h, &info, ++ NULL); ++#else ++ SoupLogger *logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1); ++ soup_logger_set_printer (logger, translate_generic_service_log_printer, NULL, NULL); ++ soup_logger_attach (logger, info.session); ++ g_object_unref (logger); ++#endif ++ } + + if (progress_func) + { +@@ -489,6 +528,7 @@ + if (flags & TRANSFER_FOLLOW_REFRESH) + g_signal_connect(message, "got-body", G_CALLBACK(translate_generic_service_refresh_got_body_h), &info); + ++#ifdef HAVE_LIBSOUP22 + /* http://bugzilla.ximian.com/show_bug.cgi?id=70688 */ + soup_message_set_flags(message, SOUP_MESSAGE_NO_REDIRECT); + soup_message_add_status_class_handler(message, +@@ -496,6 +536,7 @@ + SOUP_HANDLER_POST_BODY, + translate_generic_service_redirect_handler, + info.session); ++#endif + + if (translate_generic_debug_flags & TRANSLATE_GENERIC_DEBUG_LOG_TRANSFERS) + translate_generic_service_log_connect(message); +@@ -554,18 +595,18 @@ + + if ((charset)||(response_charset)) + { +- response = g_convert(message->response.body, message->response.length, "UTF-8", response_charset?response_charset:charset, NULL, NULL, err); ++ response = g_convert(SOUP_MESSAGE_RESPONSE_BODY (message), SOUP_MESSAGE_RESPONSE_LENGTH (message), "UTF-8", charset, NULL, NULL, err); + g_free(charset); + } + else + { +- if ((flags & TRANSFER_CONVERT) && ! g_utf8_validate(message->response.body, message->response.length, NULL)) ++ if ((flags & TRANSFER_CONVERT) && ! g_utf8_validate(SOUP_MESSAGE_RESPONSE_BODY (message), SOUP_MESSAGE_RESPONSE_LENGTH (message), NULL)) + g_set_error(err, + TRANSLATE_GENERIC_SERVICE_ERROR, + TRANSLATE_GENERIC_SERVICE_ERROR_TRANSFER, + _("invalid UTF-8")); + else +- response = g_strndup(message->response.body, message->response.length); ++ response = g_strndup(SOUP_MESSAGE_RESPONSE_BODY (message), SOUP_MESSAGE_RESPONSE_LENGTH (message)); + } + } + else +@@ -606,7 +647,7 @@ + : NULL; + + if (! value) +- value = soup_message_get_header(message->response_headers, name); ++ value = soup_message_headers_get(message->response_headers, name); + + return value; + } +@@ -614,12 +655,14 @@ + static void + translate_generic_service_log_connect (SoupMessage *message) + { +- const SoupUri *uri; ++ const SoupURI *uri; + + uri = soup_message_get_uri(message); + g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, _("connecting to %s:%i"), uri->host, uri->port); + } + ++#ifdef HAVE_LIBSOUP22 ++ + static void + translate_generic_service_log_wrote_headers_h (SoupMessage *message, + gpointer user_data) +@@ -674,6 +717,20 @@ + g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%s %s: %s", prefix, key, value); + } + ++#else /* !HAVE_LIBSOUP22 */ ++ ++static void ++translate_generic_service_log_printer (SoupLogger *logger, ++ SoupLoggerLogLevel level, ++ char direction, ++ const char *data, ++ gpointer user_data) ++{ ++ g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%c %s", direction, data); ++} ++ ++#endif /* HAVE_LIBSOUP22 */ ++ + static void + translate_generic_service_progress_got_headers_h (SoupMessage *message, + gpointer user_data) +@@ -681,7 +738,7 @@ + TransferInfo *info = user_data; + const char *content_length; + +- content_length = soup_message_get_header(message->response_headers, "Content-Length"); ++ content_length = soup_message_headers_get(message->response_headers, "Content-Length"); + info->length = (content_length + && *content_length + && strspn(content_length, "0123456789") == strlen(content_length)) +@@ -691,6 +748,9 @@ + + static void + translate_generic_service_progress_got_chunk_h (SoupMessage *message, ++#ifdef HAVE_LIBSOUP24 ++ SoupBuffer *chunk, ++#endif + gpointer user_data) + { + TransferInfo *info = user_data; +@@ -700,7 +760,11 @@ + progress = -1; + else + { ++#ifdef HAVE_LIBSOUP22 + info->received += message->response.length; ++#else ++ info->received += chunk->length; ++#endif + progress = (double) info->received / info->length; + progress = CLAMP(progress, 0.0, 1.0); + } +@@ -716,7 +780,7 @@ + TransferInfo *info = user_data; + const char *content_type; + +- content_type = soup_message_get_header(message->response_headers, "Content-Type"); ++ content_type = soup_message_headers_get(message->response_headers, "Content-Type"); + info->parse_html = content_type + && (g_str_has_prefix(content_type, "text/html") + || g_str_has_prefix(content_type, "application/xhtml+xml") +@@ -736,7 +800,7 @@ + info->html_http_equiv = NULL; + } + +- if (info->parse_html && message->response.length > 0) ++ if (info->parse_html && SOUP_MESSAGE_RESPONSE_LENGTH (message) > 0) + { + char *body; + xmlSAXHandler sax_handler = { NULL }; +@@ -750,7 +814,7 @@ + sax_handler.startElement = translate_generic_service_html_start_element_cb; + sax_handler.endElement = translate_generic_service_html_end_element_cb; + +- body = g_strndup(message->response.body, message->response.length); ++ body = g_strndup(SOUP_MESSAGE_RESPONSE_BODY (message), SOUP_MESSAGE_RESPONSE_LENGTH (message)); + htmlSAXParseDoc(body, NULL, &sax_handler, user_data); + g_free(body); + } +@@ -817,7 +881,7 @@ + { + TransferInfo *info = user_data; + const char *refresh_uri; +- SoupUri *new_uri = NULL; ++ SoupURI *new_uri = NULL; + + refresh_uri = translate_generic_service_get_header(message, info, "Refresh"); + if (refresh_uri) +@@ -832,9 +896,9 @@ + new_uri = soup_uri_new(refresh_uri); + if (! new_uri) + { +- const SoupUri *base_uri; ++ SoupURI *base_uri; + +- base_uri = soup_message_get_uri(message); ++ base_uri = (SoupURI *)soup_message_get_uri(message); + new_uri = soup_uri_new_with_base(base_uri, refresh_uri); + } + } +@@ -851,6 +915,7 @@ + } + } + ++#ifdef HAVE_LIBSOUP22 + static void + translate_generic_service_redirect_handler (SoupMessage *message, + gpointer user_data) +@@ -887,6 +952,7 @@ + soup_session_requeue_message(session, message); + } + } ++#endif + + static char * + translate_generic_service_timed_translate_text (TranslateService *service, +@@ -1391,7 +1457,7 @@ + translate_generic_service_soup_session_sync_new (void) + { + char *proxy_text_uri; +- SoupUri *proxy_uri = NULL; ++ SoupURI *proxy_uri = NULL; + SoupSession *session; + TranslateGenericSoupCookieJar *cookie_jar; + +@@ -1411,7 +1477,7 @@ + soup_uri_free(proxy_uri); + + cookie_jar = translate_generic_soup_cookie_jar_new(); +- soup_session_add_filter(session, SOUP_MESSAGE_FILTER(cookie_jar)); ++ translate_generic_soup_cookie_jar_attach(cookie_jar, session); + g_object_unref(cookie_jar); + + return session; +diff -dPNur libtranslate-0.99/src/modules/translate-generic-soup-cookie-jar.c libtranslate-0.99-1/src/modules/translate-generic-soup-cookie-jar.c +--- libtranslate-0.99/src/modules/translate-generic-soup-cookie-jar.c 2005-01-17 17:46:53.000000000 +0100 ++++ libtranslate-0.99-1/src/modules/translate-generic-soup-cookie-jar.c 2010-02-14 03:55:56.000000000 +0100 +@@ -29,9 +29,12 @@ + * POSSIBILITY OF SUCH DAMAGE. + */ + ++#include "config.h" + #include <string.h> + #include <libsoup/soup.h> ++#ifdef HAVE_LIBSOUP22 + #include <libsoup/soup-message-filter.h> ++#endif + #include "translate-generic-soup-cookie-jar.h" + + struct _TranslateGenericSoupCookieJarPrivate +@@ -44,9 +47,12 @@ + static void translate_generic_soup_cookie_jar_register_type (GType *type); + static void translate_generic_soup_cookie_jar_class_init (TranslateGenericSoupCookieJarClass *class); + static void translate_generic_soup_cookie_jar_init (TranslateGenericSoupCookieJar *jar); ++#ifdef HAVE_LIBSOUP22 + static void translate_generic_soup_cookie_jar_filter_init (SoupMessageFilterClass *iface); ++#else ++#define SoupMessageFilter TranslateGenericSoupCookieJar ++#endif + static void translate_generic_soup_cookie_jar_finalize (GObject *object); +- + static void translate_generic_soup_cookie_jar_setup_message (SoupMessageFilter *filter, + SoupMessage *message); + +@@ -75,17 +81,21 @@ + 0, + (GInstanceInitFunc) translate_generic_soup_cookie_jar_init + }; ++#ifdef HAVE_LIBSOUP22 + static const GInterfaceInfo filter_info = { + (GInterfaceInitFunc) translate_generic_soup_cookie_jar_filter_init, + NULL, + NULL + }; ++#endif + + *type = g_type_register_static(G_TYPE_OBJECT, + "TranslateGenericSoupCookieJar", + &info, + 0); ++#ifdef HAVE_LIBSOUP22 + g_type_add_interface_static(*type, SOUP_TYPE_MESSAGE_FILTER, &filter_info); ++#endif + } + + static void +@@ -107,11 +117,13 @@ + TranslateGenericSoupCookieJarPrivate); + } + ++#ifdef HAVE_LIBSOUP22 + static void + translate_generic_soup_cookie_jar_filter_init (SoupMessageFilterClass *iface) + { + iface->setup_message = translate_generic_soup_cookie_jar_setup_message; + } ++#endif + + static void + translate_generic_soup_cookie_jar_finalize (GObject *object) +@@ -125,26 +137,46 @@ + } + + static void ++add_cookie_to_jar (TranslateGenericSoupCookieJar *jar, const char *cookie) ++{ ++ char *s; ++ ++ s = strchr(cookie, ';'); ++ if (s) ++ jar->priv->cookies = g_slist_append(jar->priv->cookies, g_strndup(cookie, s - cookie)); ++} ++ ++#ifdef HAVE_LIBSOUP24 ++static void ++maybe_add_cookie_to_jar (const char *header, const char *value, gpointer jar) ++{ ++ if (!g_ascii_strcasecmp (header, "Set-Cookie")) ++ add_cookie_to_jar (jar, value); ++} ++#endif ++ ++static void + translate_generic_soup_cookie_jar_setup_message (SoupMessageFilter *filter, +- SoupMessage *message) ++ SoupMessage *message) + { + TranslateGenericSoupCookieJar *jar = TRANSLATE_GENERIC_SOUP_COOKIE_JAR(filter); +- const GSList *cookies; + const GSList *l; + + /* FIXME: add full RFC 2965 support */ + ++#ifdef HAVE_LIBSOUP22 ++ const GSList *cookies; ++ + cookies = soup_message_get_header_list(message->response_headers, "Set-Cookie"); + for (l = cookies; l != NULL; l = l->next) + { + const char *cookie = l->data; +- char *s; +- +- s = strchr(cookie, ';'); +- if (s) +- jar->priv->cookies = g_slist_append(jar->priv->cookies, g_strndup(cookie, s - cookie)); ++ add_cookie_to_jar(jar, cookie); + } +- ++#else ++ soup_message_headers_foreach(message->response_headers, maybe_add_cookie_to_jar, jar); ++#endif ++ + if (jar->priv->cookies) + { + GString *string; +@@ -159,13 +191,44 @@ + g_string_append(string, "; "); + } + ++#ifdef HAVE_LIBSOUP22 + soup_message_add_header(message->request_headers, "Cookie", string->str); ++#else ++ soup_message_headers_append(message->request_headers, "Cookie", string->str); ++#endif + g_string_free(string, TRUE); + } + } + ++#ifdef HAVE_LIBSOUP24 ++static void ++translate_generic_soup_cookie_jar_request_started (SoupSession *session, ++ SoupMessage *message, ++ SoupSocket *socket, ++ gpointer cookie_jar) ++{ ++ translate_generic_soup_cookie_jar_setup_message (cookie_jar, message); ++} ++#endif ++ + TranslateGenericSoupCookieJar * + translate_generic_soup_cookie_jar_new (void) + { + return g_object_new(TRANSLATE_GENERIC_TYPE_SOUP_COOKIE_JAR, NULL); + } ++ ++void ++translate_generic_soup_cookie_jar_attach (TranslateGenericSoupCookieJar *cookie_jar, ++ SoupSession *session) ++{ ++#ifdef HAVE_LIBSOUP22 ++ soup_session_add_filter (session, SOUP_MESSAGE_FILTER(cookie_jar)); ++#else ++ g_signal_connect (session, "request_started", ++ G_CALLBACK (translate_generic_soup_cookie_jar_request_started), ++ cookie_jar); ++ g_object_set_data_full (G_OBJECT (session), "TranslateGenericSoupCookieJar", ++ g_object_ref (cookie_jar), g_object_unref); ++#endif ++} ++ +diff -dPNur libtranslate-0.99/src/modules/translate-generic-soup-cookie-jar.h libtranslate-0.99-1/src/modules/translate-generic-soup-cookie-jar.h +--- libtranslate-0.99/src/modules/translate-generic-soup-cookie-jar.h 2005-01-17 17:47:00.000000000 +0100 ++++ libtranslate-0.99-1/src/modules/translate-generic-soup-cookie-jar.h 2010-02-14 03:55:56.000000000 +0100 +@@ -33,6 +33,7 @@ + #define _TRANSLATE_GENERIC_SOUP_COOKIE_JAR_H + + #include <glib-object.h> ++#include <libsoup/soup-session.h> + + #define TRANSLATE_GENERIC_TYPE_SOUP_COOKIE_JAR (translate_generic_soup_cookie_jar_get_type()) + #define TRANSLATE_GENERIC_SOUP_COOKIE_JAR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TRANSLATE_GENERIC_TYPE_SOUP_COOKIE_JAR, TranslateGenericSoupCookieJar)) +@@ -59,5 +60,6 @@ + + GType translate_generic_soup_cookie_jar_get_type (void); + TranslateGenericSoupCookieJar *translate_generic_soup_cookie_jar_new (void); ++void translate_generic_soup_cookie_jar_attach (TranslateGenericSoupCookieJar *cookie_jar, SoupSession *session); + + #endif /* _TRANSLATE_GENERIC_SOUP_COOKIE_JAR_H */ diff --git a/app-dicts/libtranslate/files/services.xml b/app-dicts/libtranslate/files/services.xml new file mode 100644 index 0000000..14d0548 --- /dev/null +++ b/app-dicts/libtranslate/files/services.xml @@ -0,0 +1,258 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE services SYSTEM "services.dtd"> +<services> + <custom-language tag="zh-TW" name="Chinese (Taiwan)"/> + + <service nick="Google" name="google"> + <group> + <language to="*" tag="en"/> + <language to="en,de" tag="fr"/> + <language to="en,fr" tag="de"/> + <language to="en" tag="it"/> + <language to="en" tag="pt"/> + <language to="en" tag="es"/> + <language to="en" tag="pt"/> + <language to="en" tag="ru"/> + <language to="en" tag="zh"/> + <language to="en" tag="zh-TW"/> + <language to="en" tag="ja"/> + <language to="en" tag="ko"/> + <language to="en" tag="ar"/> + <text-translation url="http://www.google.com/translate_t?text=${text:escape}&langpair=${from}|${to}&ie=utf8&oe=utf8"> + <pre-marker text="id=result_box"/> + <pre-marker text="mouseover"/> + <pre-marker text=">"/> + <post-marker text="<br>"/> + </text-translation> + <web-page-translation url="http://www.google.com/translate_c?u=${url:escape}&langpair=${from}|${to}"/> + </group> + </service> + + <service nick="FreeTranslation" name="freetranslation" max-chunk-len="600"> + <group> + <language to="en" tag="nl" service-tag="dutch"/> + <language to="*" tag="en" service-tag="english"/> + <language to="en" tag="fr" service-tag="french"/> + <language to="en" tag="de" service-tag="german"/> + <language to="en" tag="it" service-tag="italian"/> + <language tag="no" service-tag="norwegian"/> + <language to="en" tag="pt" service-tag="portuguese"/> + <language to="en" tag="es" service-tag="spanish"/> + <text-translation url="http://ets.freetranslation.com/?sequence=core&srctext=${text:escape}&language=${from}/${to}&charset=utf-8"/> + <web-page-translation url="http://fets5.freetranslation.com/?sequence=core&url=${url:escape}&language=${from}/${to}"/> + </group> + <group> + <language tag="zh" service-tag="simplifiedchinese"/> + <language tag="zh-TW" service-tag="traditionalchinese"/> + <language to="*" tag="en" service-tag="english"/> + <language to="en" tag="ru" service-tag="russian"/> + <text-translation url="http://ets6.freetranslation.com/?sequence=core&srctext=${text:escape}&language=${from}/${to}&charset=utf-8"/> + </group> + <group> + <language to="*" tag="en" service-tag="english"/> + <language to="en" tag="ja" service-tag="japanese"/> + <text-translation url="http://tets9.freetranslation.com/?sequence=core&srctext=${text:escape}&language=${from}/${to}&charset=utf-8"/> + </group> + </service> + + <service nick="Pereklad" name="pereklad"> + <group> + <language to="*" tag="ru" service-tag="Rus"/> + <language to="*" tag="uk" service-tag="Ukr"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:escape}"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + <group> + <language to="*" tag="en" service-tag="Eng"/> + <language to="*" tag="de" service-tag="Ger"/> + <language to="*" tag="fr" service-tag="Fra"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:escape}" + response-charset="ISO-8859-1"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + <group> + <language to="en,de,fr" tag="ru" service-tag="Rus"/> + <language to="en,de,fr" tag="uk" service-tag="Ukr"/> + <language to="" tag="en" service-tag="Eng"/> + <language to="" tag="de" service-tag="Ger"/> + <language to="" tag="fr" service-tag="Fra"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:escape}" + response-charset="ISO-8859-1"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + <group> + <language to="" tag="ru" service-tag="Rus"/> + <language to="" tag="uk" service-tag="Ukr"/> + <language to="ru,uk" tag="en" service-tag="Eng"/> + <language to="ru,uk" tag="de" service-tag="Ger"/> + <language to="ru,uk" tag="fr" service-tag="Fra"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:escape}"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + <group> + <language to="" tag="ru" service-tag="Rus"/> + <language to="" tag="uk" service-tag="Ukr"/> + <language to="ru,uk" tag="lv" service-tag="Lat"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:escape}"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + <group> + <language to="*" tag="lv" service-tag="Lat"/> + <language to="" tag="en" service-tag="Eng"/> + <language to="" tag="de" service-tag="Ger"/> + <language to="" tag="fr" service-tag="Fra"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:escape}" + response-charset="ISO-8859-1"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + <group> + <language to="" tag="lv" service-tag="Lat"/> + <language to="lv" tag="ru" service-tag="Rus"/> + <language to="lv" tag="uk" service-tag="Ukr"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:escape}" + response-charset="ISO-8859-4"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + <group> + <language to="" tag="lv" service-tag="Lat"/> + <language to="lv" tag="en" service-tag="Eng"/> + <language to="lv" tag="de" service-tag="Ger"/> + <language to="lv" tag="fr" service-tag="Fra"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:escape}" + response-charset="ISO-8859-4"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + </service> + + <service nick="Promt" name="promt"> + <group> + <language to="*" tag="ru" service-tag="r"/> + <language to="ru,de,fr,es" tag="en" service-tag="e"/> + <language to="ru,en,fr,es" tag="de" service-tag="g"/> + <language to="ru,en,de,es" tag="fr" service-tag="f"/> + <language to="ru,en" tag="it" service-tag="i"/> + <language to="ru,en,de,fr" tag="es" service-tag="s"/> + <language to="en" tag="pt" service-tag="p"/> + <text-translation + url="http://www.translate.ru/Default.aspx/Text" + post="__EVENTTARGET=&__EVENTTARGUMENT=&ctl00$SiteContent$MA_trasnlform$bTranslate=Translate&ctl00$SiteContent$MA_trasnlform$DropDownList2=&ctl00$SiteContent$trasnlform$sLang=${from}&ctl00$SiteContent$MA_trasnlform$rLang=${to}&ctl00$SiteContent$MA_trasnlform$sourceText=${text:escape}&ctl00$SiteContent$MA_trasnlform$rblTemplates=General"> + <pre-marker text="ctl00$SiteContent$MA_trasnlform$tbPismo"/> + <pre-marker text=">"/> + <post-marker text="</textarea"/> + + </text-translation> + </group> + </service> + + <service nick="SYSTRAN" name="systran"> + <group> + <language to="en" tag="ar"/> + <language to="en" tag="zh"/> + <language to="en" tag="zh-TW" service-tag="zt"/> + <language to="en,fr" tag="nl"/> + <language to="*" tag="en"/> + <language to="nl,en,de,it,pt,es" tag="fr"/> + <language to="en,fr" tag="de"/> + <language to="en,fr" tag="it"/> + <language to="en" tag="ja"/> + <language to="en" tag="ko"/> + <language to="en,fr" tag="pt"/> + <language to="en" tag="ru"/> + <language to="en,fr" tag="es"/> + <language to="en" tag="sv"/> + <http-header value="http://www.systransoft.com/" name="Referer"/> + <text-translation + url="http://www.systranet.com/tt?lp=${from}_${to}&service=translate" + post=". ${text}."> + <pre-marker text=". "/> + <post-marker text="."/> + </text-translation> + </group> + </service> + + <service nick="Babel Fish" name="babelfish"> + <group> + <language to="en" tag="zh"/> + <language to="en" tag="zh-TW" service-tag="zt"/> + <language to="*" tag="en"/> + <language to="en,fr" tag="nl"/> + <language to="en,de,el,it,pt,nl,es" tag="fr"/> + <language to="en,fr" tag="de"/> + <language to="en,fr" tag="el"/> + <language to="en,fr" tag="it"/> + <language to="en" tag="ja"/> + <language to="en" tag="ko"/> + <language to="en,fr" tag="pt"/> + <language to="en" tag="ru"/> + <language to="en,fr" tag="es"/> + <text-translation + url="http://babelfish.yahoo.com/translate_txt" + post="trtext=${text:escape}&lp=${from}_${to}&ei=UTF-8"> + <pre-marker text="id="result""/> + <pre-marker text="<div"/> + <pre-marker text=">"/> + <post-marker text="</div"/> + </text-translation> +<!-- + <web-page-translation url="http://babelfish.altavista.com/babelfish/trurl_load?url=${url:escape}&lp=${from}_${to}&enc=utf8"/> +!--> + </group> + </service> + +<!-- + <service nick="Kataku" name="kataku"> + <group> + <language to="*" tag="en"/> + <language to="*" tag="id" service-tag="in"/> + <text-translation url="http://www.toggletext.com/kataku_trial.php" post="input_text=${text:charset=ISO8859-1,escape}&langset_text=${from}_${to}"> + <pre-marker text="Translation:"/> + <pre-marker text="<pre"/> + <pre-marker text=">"/> + <post-marker text=" </pre>"/> + </text-translation> + <web-page-translation url="http://www.toggletext.com/kataku_webpage_translate.php?input=${url:escape}&langset=${from}_${to}"/> + </group> + </service> +--> + +</services>
\ No newline at end of file diff --git a/app-dicts/libtranslate/libtranslate-0.99-r4.ebuild b/app-dicts/libtranslate/libtranslate-0.99-r4.ebuild new file mode 100644 index 0000000..59e4e78 --- /dev/null +++ b/app-dicts/libtranslate/libtranslate-0.99-r4.ebuild @@ -0,0 +1,45 @@ +# Copyright 1999-2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +inherit eutils + +DESCRIPTION="Library for translating text and web pages between natural languages." +HOMEPAGE="http://www.nongnu.org/libtranslate" +SRC_URI="http://savannah.nongnu.org/download/libtranslate/${P}.tar.gz" + +SLOT="0" +KEYWORDS="x86 amd64" +LICENSE="BSD" +IUSE="" + + +DEPEND=">=dev-libs/glib-2.4.0 + >=net-libs/libsoup-2.2.0 + >=dev-libs/libxml2-2.0 + app-text/talkfilters + dev-perl/XML-Parser" + + +src_unpack() { + unpack ${A} + cd ${S} + epatch "${FILESDIR}"/libtranslate-ds-timed.patch.bz2 + epatch "${FILESDIR}"/libtranslate-ds-memory.patch + + epatch "${FILESDIR}"/libtranslate-0.99-charsetparse.diff + epatch "${FILESDIR}"/libtranslate-0.99-condfix.diff + epatch "${FILESDIR}"/libtranslate-ds-empty.patch + epatch "${FILESDIR}"/libtranslate-ds-promt.patch + epatch "${FILESDIR}"/libtranslate-ds-fixcharset.patch +} + +src_install() { +# Installing new services.xml without broken items + cp -f ${FILESDIR}/services.xml data/ + + make install DESTDIR="${D}" + + cd ${S} + dodoc AUTHORS COPYING INSTALL NEWS README TODO +} diff --git a/app-dicts/libtranslate/libtranslate-0.99-r6.ebuild b/app-dicts/libtranslate/libtranslate-0.99-r6.ebuild new file mode 100644 index 0000000..e150735 --- /dev/null +++ b/app-dicts/libtranslate/libtranslate-0.99-r6.ebuild @@ -0,0 +1,58 @@ +# Copyright 1999-2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +inherit eutils + +DESCRIPTION="Library for translating text and web pages between natural languages." +HOMEPAGE="http://www.nongnu.org/libtranslate" +SRC_URI="http://savannah.nongnu.org/download/libtranslate/${P}.tar.gz" + +SLOT="0" +KEYWORDS="x86 amd64" +LICENSE="BSD" +IUSE="" + + +DEPEND=">=dev-libs/glib-2.4.0 + dev-util/intltool + >=net-libs/libsoup-2.4.0 + >=dev-libs/libxml2-2.0 + app-text/talkfilters + dev-perl/XML-Parser" + + +src_unpack() { + unpack ${A} + cd ${S} + epatch "${FILESDIR}"/libtranslate-ds-timed24.patch || die + epatch "${FILESDIR}"/libtranslate-ds-memory.patch || die + + epatch "${FILESDIR}"/libtranslate-0.99-charsetparse.diff || die + epatch "${FILESDIR}"/libtranslate-0.99-condfix.diff || die + epatch "${FILESDIR}"/libtranslate-ds-empty.patch || die + epatch "${FILESDIR}"/libtranslate-ds-promt.patch || die + epatch "${FILESDIR}"/libtranslate-ds-fixcharset.patch || die + epatch "${FILESDIR}"/libtranslate-soup24inc.patch || die +} + +src_compile() { + rm -f Makefile.in aclocal.m4 + aclocal -I m4 || die + intltoolize --force || die + libtoolize || die + automake --add-missing || die + autoconf || die + econf + emake +} + +src_install() { +# Installing new services.xml without broken items + cp -f ${FILESDIR}/services.xml data/ + + make install DESTDIR="${D}" + + cd ${S} + dodoc AUTHORS COPYING INSTALL NEWS README TODO +} |