2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <systemd/sd-daemon.h>
23 #include <glib-object.h>
24 #include <curl/curl.h>
26 #include "download-provider-config.h"
27 #include "download-provider-log.h"
28 #include "download-provider-client-manager.h"
29 #include "download-provider-network.h"
31 pthread_t g_client_manager_tid;
32 void *dp_client_manager(void *arg);
34 int main(int argc, char **argv)
36 GMainLoop *event_loop;
37 TRACE_INFO("download-provider's working is started");
39 event_loop = g_main_loop_new(NULL, FALSE);
41 TRACE_ERROR("Failed to create g main loop handle");
44 // check network status
45 if (dp_network_connection_init() < 0) {
46 TRACE_ERROR("failed to init network-manager");
49 //Requested By platform team, It should be in main thread.
50 curl_global_init(CURL_GLOBAL_ALL);
52 // create a thread for main thread
53 if (pthread_create(&g_client_manager_tid, NULL, dp_client_manager, (void *)event_loop) != 0) {
54 TRACE_ERROR("failed to create main thread");
55 curl_global_cleanup();
58 pthread_detach(g_client_manager_tid);
59 TRACE_INFO("download main thread is created[%lu]", g_client_manager_tid);
62 TRACE_INFO("g main loop is started");
63 g_main_loop_run(event_loop);
64 curl_global_cleanup();
65 dp_network_connection_destroy();
66 g_main_loop_unref(event_loop);
68 TRACE_INFO("download-provider's working is done");