~ubuntu-branches/ubuntu/trusty/xiphos/trusty

« back to all changes in this revision

Viewing changes to src/main/main.c

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs, Dmitrijs Ledkovs
  • Date: 2012-03-11 18:43:32 UTC
  • mfrom: (17.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120311184332-splq3ecpx7tyi87d
Tags: 3.1.5+dfsg-1
[ Dmitrijs Ledkovs <dmitrij.ledkov@ubuntu.com> ]  
* New upstream release.
* Build using webkit backend
* Contains unpacked source for waf binary (Closes: #654511)
* Update debian/copyright to latest specification

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Xiphos Bible Study Tool
3
3
 * main.c - In the beginning... ;o)
4
4
 *
5
 
 * Copyright (C) 2000-2010 Xiphos Developer Team
 
5
 * Copyright (C) 2000-2011 Xiphos Developer Team
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or modify
8
8
 * it under the terms of the GNU General Public License as published by
41
41
#include "main/sword.h"
42
42
#include "main/url.hh"
43
43
#include "main/xml.h"
44
 
#ifdef USE_GTKMOZEMBED
45
 
#ifdef WIN32
46
 
#include "geckowin/gecko-html.h"
47
 
#else
48
 
#include "gecko/gecko-html.h"
49
 
#endif
50
 
#endif
 
44
#include "../xiphos_html/xiphos_html.h"
51
45
//#include "backend/sword.h"
52
46
 
53
47
#include "gui/debug_glib_null.h"
54
48
 
55
49
#include <glib/gstdio.h>
56
50
 
 
51
#ifdef WIN32
 
52
 
 
53
/*
 
54
 * this is, we hope, a temporary fix for the webkit image display problem.
 
55
 * we instantiate a local web server (!) so as to self-serve image files
 
56
 * whose size we have already otherwise determined using local path.
 
57
 */
 
58
 
 
59
#include <libsoup/soup.h>
 
60
 
 
61
static void
 
62
server_callback_media (SoupServer *server,
 
63
                       SoupMessage *msg,
 
64
                       const char *path,
 
65
                       GHashTable *query,
 
66
                       SoupClientContext *client,
 
67
                       gpointer user_data)
 
68
{
 
69
        char *contents;
 
70
        gsize length;
 
71
        GError *error = NULL;
 
72
        gchar *real_path;
 
73
 
 
74
        real_path = g_strdup(path);
 
75
        real_path++;
 
76
 
 
77
        if (!g_file_test(real_path, G_FILE_TEST_EXISTS))
 
78
                return;
 
79
        g_file_get_contents(real_path, &contents, &length, &error);
 
80
        g_assert(!error);
 
81
 
 
82
        soup_message_body_append(msg->response_body, SOUP_MEMORY_TAKE,
 
83
                                 contents, length);
 
84
        soup_message_set_status(msg, SOUP_STATUS_OK);
 
85
}
 
86
#endif /* WIN32 */
 
87
 
57
88
/******************************************************************************
58
89
 * Name
59
90
 *   main
76
107
        int have_sword_url = FALSE;
77
108
        int have_tab_list = FALSE;
78
109
        gint base_step = 0; //needed for splash
 
110
#ifdef WIN32
 
111
        /* see comments on function immediately preceding. */
 
112
        SoupServer *server;
 
113
#endif
 
114
#ifdef DEBUG
79
115
        GTimer *total;
80
116
        double d;
 
117
#endif
81
118
 
82
119
        //      g_thread_init(NULL);
83
120
        g_type_init();
 
121
 
 
122
#ifdef DEBUG
84
123
        total = g_timer_new();
 
124
#endif
 
125
 
85
126
 
86
127
#ifdef WIN32
87
128
        /*
116
157
        /* we need an idea of $HOME that's convenient. */
117
158
        /* this gives us linux-equivalent semantics. */
118
159
        g_setenv("HOME", g_getenv("APPDATA"), TRUE);
 
160
 
 
161
        /* see comments near top of file. */
 
162
        server = soup_server_new(SOUP_SERVER_PORT, 7878, NULL);
 
163
        soup_server_add_handler(server, "/", server_callback_media,
 
164
                                NULL, NULL);
 
165
        soup_server_run_async(server);
119
166
#endif /* WIN32 */
120
167
 
121
168
        if (argc > 2) {
163
210
 
164
211
        gui_splash_init();
165
212
 
166
 
#ifdef USE_GTKMOZEMBED
167
 
 
168
 
        gui_splash_step(_("Initiating Gecko"), 0.0, 0);
169
 
 
170
 
        gecko_html_initialize();
 
213
#ifdef USE_XIPHOS_HTML
 
214
 
 
215
        gui_splash_step(_("Initiating HTML"), 0.0, 0);
 
216
        
 
217
        XIPHOS_HTML_INITIALIZE();
171
218
 
172
219
        base_step = 1;
173
220
#endif
202
249
                main_url_handler(argv[1], TRUE);
203
250
        }
204
251
 
 
252
#ifdef DEBUG
205
253
        g_timer_stop(total);
206
254
        d = g_timer_elapsed(total, NULL);
207
 
#ifdef DEBUG
208
255
        printf("total time is %f\n", d);
209
256
#endif
210
257
        g_idle_add ((GSourceFunc)gui_splash_done, NULL);
211
258
 
 
259
        gui_recompute_shows(FALSE);
 
260
 
212
261
        gui_main();
213
262
        return 0;
214
263
}