Changeset 6589 for branches

Show
Ignore:
Timestamp:
12/04/10 14:12:06 (22 months ago)
Author:
westram
Message:
Location:
branches/stable_5.0
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • branches/stable_5.0/AWT/AWT_www.cxx

    r6100 r6589  
    1313#include <arbdbt.h> 
    1414#include <awt.hxx> 
     15#include <inline.h> 
     16#include <static_assert.h> 
    1517 
    1618#include "awt_config_manager.hxx" 
    1719 
    1820#define WWW_COUNT                10 
    19 // #define AWAR_WWW_BROWSER "www/browser" // now defined by ARB_init_global_awars() 
    2021#define AWAR_WWW_SELECT          "www/url_select" 
    21 #define AWAR_WWW_0               "www/url_0/srt" 
    22 #define AWAR_WWW_1               "www/url_0/srt" 
    23 #define AWAR_WWW_2               "www/url_0/srt" 
    2422#define AWAR_WWW_SELECT_TEMPLATE "www/url_%i/select" 
    2523#define AWAR_WWW_TEMPLATE        "www/url_%i/srt" 
    2624#define AWAR_WWW_DESC_TEMPLATE   "www/url_%i/desc" 
    2725 
    28  
    29  
    30 void awt_create_aww_vars(AW_root *aw_root,AW_default aw_def){ 
    31     int i; 
    32     for (i=0;i<WWW_COUNT;i++){ 
    33         const char *awar_name; 
    34  
    35         awar_name = GBS_global_string(AWAR_WWW_TEMPLATE,i);         aw_root->awar_string(awar_name,i==WWW_COUNT-1?"\"http://www.ebi.ac.uk/cgi-bin/emblfetch?\";readdb(acc)":"",aw_def); 
    36         awar_name = GBS_global_string(AWAR_WWW_DESC_TEMPLATE,i);    aw_root->awar_string(awar_name,i==WWW_COUNT-1?"EMBL example":"",aw_def); 
    37         awar_name = GBS_global_string(AWAR_WWW_SELECT_TEMPLATE,i);  aw_root->awar_int(awar_name,0,aw_def); 
    38     } 
    39  
    40     aw_root->awar_int(AWAR_WWW_SELECT,0,aw_def); 
    41  
     26inline char *extract_url_host(const char *templ) { 
     27    const char *url_start = strstr(templ, "\"http://"); 
     28    if (url_start) { 
     29        const char *host_start = url_start+8; 
     30        const char *slash      = strchr(host_start, '/'); 
     31 
     32        if (slash) return GB_strpartdup(host_start, slash-1); 
     33    } 
     34    return NULL; 
     35} 
     36 
     37inline bool url_host_matches(const char *templ1, const char *templ2) { 
     38    bool  matches = false; 
     39    char *url1    = extract_url_host(templ1); 
     40    if (url1) { 
     41        char *url2 = extract_url_host(templ2); 
     42        matches = url1 && url2 && ARB_stricmp(url1, url2) == 0; 
     43        free(url2); 
     44    } 
     45    free(url1); 
     46    return matches; 
     47} 
     48 
     49void awt_create_aww_vars(AW_root *aw_root, AW_default aw_def) { 
     50    struct Example { 
     51        const char *descr; 
     52        const char *templ; 
     53    } example[] = { 
     54        { "EMBL example",   "\"http://www.ebi.ac.uk/ena/data/view/\";readdb(acc)" }, 
     55        { "SILVA example",  "\"http://www.arb-silva.de/browser/ssu/\";readdb(acc)" }, 
     56        { "Google example", "\"http://www.google.com/search?q=\";readdb(full_name);|srt(\": =+\")" } 
     57    }, empty = { "", "" }; 
     58 
     59    const int DEFAULT_SELECT = 1; // SILVA 
     60    const int EXAMPLE_COUNT  = sizeof(example)/sizeof(*example); 
     61    COMPILE_ASSERT(EXAMPLE_COUNT <= WWW_COUNT); 
     62 
     63    bool example_url_seen[EXAMPLE_COUNT]; 
     64    for (int x = 0; x<EXAMPLE_COUNT; ++x) example_url_seen[x] = false; 
     65 
     66    AW_awar *awar_templ[WWW_COUNT]; 
     67    AW_awar *awar_descr[WWW_COUNT]; 
     68    bool     is_empty[WWW_COUNT]; 
     69 
     70    for (int i = 0; i<WWW_COUNT; ++i) { 
     71        const Example&  curr = i<EXAMPLE_COUNT ? example[i] : empty; 
     72        const char     *awar_name; 
     73 
     74        awar_name     = GBS_global_string(AWAR_WWW_TEMPLATE, i); 
     75        awar_templ[i] = aw_root->awar_string(awar_name, curr.templ, aw_def); 
     76 
     77        awar_name     = GBS_global_string(AWAR_WWW_DESC_TEMPLATE, i); 
     78        awar_descr[i] = aw_root->awar_string(awar_name, curr.descr, aw_def); 
     79 
     80        const char *templ = awar_templ[i]->read_char_pntr(); 
     81        const char *descr = awar_descr[i]->read_char_pntr(); 
     82 
     83        is_empty[i] = !templ[0] && !descr[0]; 
     84        if (!is_empty[i]) { 
     85            for (int x = 0; x<EXAMPLE_COUNT; ++x) { 
     86                if (!example_url_seen[x]) { 
     87                    example_url_seen[x] = url_host_matches(templ, example[x].templ); 
     88                } 
     89            } 
     90        } 
     91 
     92        awar_name = GBS_global_string(AWAR_WWW_SELECT_TEMPLATE, i); 
     93        aw_root->awar_int(awar_name, 0, aw_def); 
     94    } 
     95 
     96    // insert missing examples 
     97    for (int x = 0; x<EXAMPLE_COUNT; ++x) { 
     98        if (!example_url_seen[x]) { 
     99            for (int i = 0; i<WWW_COUNT; ++i) { 
     100                if (is_empty[i]) { 
     101                    awar_templ[i]->write_string(example[x].templ); 
     102                    awar_descr[i]->write_string(example[x].descr); 
     103                    is_empty[i] = false; 
     104                    break; 
     105                } 
     106            } 
     107        } 
     108    } 
     109 
     110    aw_root->awar_int(AWAR_WWW_SELECT, DEFAULT_SELECT, aw_def); 
    42111    awt_assert(ARB_global_awars_initialized()); 
    43112} 
     
    99168    error                        = awt_open_ACISRT_URL_by_gbd(aw_root, gb_main, gbd, name, url_srt); 
    100169 
    101     delete url_srt; 
     170    free(url_srt); 
    102171    return error; 
    103172} 
  • branches/stable_5.0/AWT/Makefile

    r6062 r6589  
    655655AWT_www.o: $(ARBHOME)/INCLUDE/aw_root.hxx 
    656656AWT_www.o: $(ARBHOME)/INCLUDE/aw_window.hxx 
     657AWT_www.o: $(ARBHOME)/INCLUDE/inline.h 
  • branches/stable_5.0/HELP_SOURCE/oldhelp/props_www.hlp

    r2986 r6589  
    2424EXAMPLES        Here are some search examples (URL-Entries): 
    2525 
    26                 Retrieve from EMBL-Database: 
    27                         "http://www.ebi.ac.uk/cgi-bin/emblfetch?";readdb(acc) 
     26                Search in ARB-SILVA: 
     27                       "http://www.arb-silva.de/browser/ssu/";readdb(acc) 
    2828 
    29                 Search Medline for related information: 
    30                         "http://www.ncbi.nlm.nih.gov/htbin-post/Entrez/query?uid=";readdb(medline_id);"&form=6&db=m&Dopt=b" 
     29                Search in EMBL: 
     30                       "http://www.ebi.ac.uk/ena/data/view/";readdb(acc) 
    3131 
    3232                Search the Web for full-name using google: 
    33                        "http://www.google.com/search?q=";readdb(full_name);"&ie=ISO-8859-1&hl=de&btnG=Google-Suche&meta="|srt(": =+") 
     33                       "http://www.google.com/search?q=";readdb(full_name);|srt(": =+")" 
    3434 
    3535 
     
    3838                preferred internet browser. 
    3939 
    40                 Netscape user enter: 
     40                Generic methods: 
    4141 
    42                     (netscape -remote 'openURL($(URL))' || netscape '$(URL)') & 
     42                    xdg-open "$(URL)" 
    4343 
    44                 Opera users enter one of: 
    45  
    46                     opera -remote 'openURL($(URL))' & 
    47  
    48                     opera -remote 'openURL($(URL),new-window)' & 
    49  
    50  
     44                    open "$(URL)"               (OSX) 
    5145 
    5246WARNINGS        We are not responsible for any content you retrieve by using 
    53                 this function. Only use this at your own responsibility. 
     47                this function. Use this at your own responsibility. 
    5448 
    5549BUGS            No bugs known 
  • branches/stable_5.0/WINDOW/AW_global_awars.cxx

    r5948 r6589  
    106106} 
    107107 
     108#if defined(DARWIN) 
     109#define OPENURL "open"     
     110#else 
     111#define OPENURL "xdg-open" 
     112#endif // DARWIN 
     113 
    108114GB_ERROR ARB_init_global_awars(AW_root *aw_root, AW_default aw_def, GBDATA *gb_main) { 
    109115    aw_assert(!initialized);    // don't call twice! 
     
    112118    gb_main4awar = gb_main; 
    113119 
    114     GB_ERROR error = aw_root->awar_string(AWAR_WWW_BROWSER, "(netscape -remote 'openURL($(URL))' || netscape '$(URL)') &", aw_def)->make_global(); 
     120    GB_ERROR error = aw_root->awar_string(AWAR_WWW_BROWSER, OPENURL " \"$(URL)\"", aw_def)->make_global(); 
    115121 
    116122    if (!error) { 
  • branches/stable_5.0/WINDOW/aw_global_awars.hxx

    r5675 r6589  
    1616#define AW_GLOBAL_AWARS_HXX 
    1717 
    18 #define AWAR_WWW_BROWSER "www/browser" // how to call the users browser 
     18#define AWAR_WWW_BROWSER "www/browse_cmd" // how to call the users browser 
    1919 
    2020#else