blob: 9c7d74bbc3fb7648d0e5b919e02e4cb20723bbd7 [file] [log] [blame]
adamdunkels1103ef92003-04-02 09:17:18 +00001/*
2 * Copyright (c) 2002, Adam Dunkels.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer in the documentation and/or other materials provided
13 * with the distribution.
adamdunkels408c2b52004-06-06 07:05:40 +000014 * 3. The name of the author may not be used to endorse or promote
adamdunkels1103ef92003-04-02 09:17:18 +000015 * products derived from this software without specific prior
16 * written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * This file is part of the Contiki desktop environment
31 *
adamdunkels22abf982004-09-01 20:34:06 +000032 * $Id: contiki-main.c,v 1.14 2004/09/01 20:34:18 adamdunkels Exp $
adamdunkels1103ef92003-04-02 09:17:18 +000033 *
34 */
35
adamdunkels16a7b262004-07-04 21:15:53 +000036#include "ek.h"
37#include "clock.h"
adamdunkelsc8d51892003-08-31 22:20:52 +000038
39#include <gdk/gdktypes.h>
40#include <gtk/gtk.h>
41
adamdunkels16a7b262004-07-04 21:15:53 +000042#include "uip.h"
43#include "ctk.h"
adamdunkels408c2b52004-06-06 07:05:40 +000044
adamdunkels779b9242004-08-11 21:26:22 +000045#include "ctk-vncserver.h"
46#include "ctk-termtelnet.h"
47
48#include "cfs-posix.h"
49
adamdunkels16a7b262004-07-04 21:15:53 +000050#include "uip-fw.h"
adamdunkels408c2b52004-06-06 07:05:40 +000051
adamdunkels16a7b262004-07-04 21:15:53 +000052#include "about-dsc.h"
53#include "calc-dsc.h"
adamdunkels779b9242004-08-11 21:26:22 +000054#include "editor-dsc.h"
adamdunkels16a7b262004-07-04 21:15:53 +000055#include "email-dsc.h"
adamdunkels779b9242004-08-11 21:26:22 +000056#include "ftp-dsc.h"
adamdunkels22abf982004-09-01 20:34:06 +000057#include "irc-dsc.h"
adamdunkels16a7b262004-07-04 21:15:53 +000058#include "netconf-dsc.h"
59#include "processes-dsc.h"
60#include "shell-dsc.h"
61#include "www-dsc.h"
adamdunkels408c2b52004-06-06 07:05:40 +000062
adamdunkels408c2b52004-06-06 07:05:40 +000063
adamdunkels408c2b52004-06-06 07:05:40 +000064
65void tapdev_send(void);
66static struct uip_fw_netif tapif =
67 {UIP_FW_NETIF(0,0,0,0, 0,0,0,0, tapdev_send)};
adamdunkelsc8d51892003-08-31 22:20:52 +000068
adamdunkels12ebc1a2003-08-11 22:19:19 +000069
adamdunkels1103ef92003-04-02 09:17:18 +000070static gint
71idle_callback(gpointer data)
72{
adamdunkels408c2b52004-06-06 07:05:40 +000073
adamdunkels16a7b262004-07-04 21:15:53 +000074 ek_run();
adamdunkels1103ef92003-04-02 09:17:18 +000075 return TRUE;
76}
77/*-----------------------------------------------------------------------------------*/
78int
79main(int argc, char **argv)
80{
adamdunkels1354b512003-04-17 20:07:23 +000081 u16_t addr[2];
adamdunkels408c2b52004-06-06 07:05:40 +000082
adamdunkels779b9242004-08-11 21:26:22 +000083 /* html_test();*/
84
85 gtk_init(&argc, &argv);
86
87 ek_init();
88
89 tcpip_init(NULL);
90
adamdunkels16a7b262004-07-04 21:15:53 +000091 ctk_gtksim_service_init(NULL);
92 ctk_init();
93
adamdunkels22abf982004-09-01 20:34:06 +000094 /* ctk_vncserver_init(NULL); */
adamdunkels779b9242004-08-11 21:26:22 +000095 /* ctk_termtelnet_init(NULL);*/
96
adamdunkels16a7b262004-07-04 21:15:53 +000097 uip_init();
98 uip_ipaddr(addr, 192,168,2,2);
99 uip_sethostaddr(addr);
100
101 uip_ipaddr(addr, 192,168,2,1);
102 uip_setdraddr(addr);
103
104 uip_ipaddr(addr, 255,255,255,0);
105 uip_setnetmask(addr);
106
107
108 resolv_init(NULL);
adamdunkels12ebc1a2003-08-11 22:19:19 +0000109
adamdunkels16a7b262004-07-04 21:15:53 +0000110 tapdev_init();
111 uip_fw_service_init();
112 uip_fw_init();
113 uip_fw_default(&tapif);
114
115 /* tapdev_service_init(NULL);*/
116
117
118 program_handler_init();
119 program_handler_add(&about_dsc, "About", 1);
120 program_handler_add(&netconf_dsc, "Network setup", 1);
adamdunkels779b9242004-08-11 21:26:22 +0000121 program_handler_add(&ftp_dsc, "FTP client", 1);
122 program_handler_add(&editor_dsc, "Editor", 1);
adamdunkels16a7b262004-07-04 21:15:53 +0000123 program_handler_add(&www_dsc, "Web browser", 1);
124 program_handler_add(&processes_dsc, "Processes", 1);
125 program_handler_add(&shell_dsc, "Command shell", 1);
126 program_handler_add(&calc_dsc, "Calculator", 1);
127 program_handler_add(&email_dsc, "E-mail", 1);
adamdunkels22abf982004-09-01 20:34:06 +0000128
129 program_handler_add(&irc_dsc, "IRC", 1);
adamdunkels16a7b262004-07-04 21:15:53 +0000130
131 gtk_timeout_add(20, idle_callback, NULL);
adamdunkels779b9242004-08-11 21:26:22 +0000132
133
134 cfs_posix_init(NULL);
135
136 /* sock_httpd_init(NULL);*/
137
adamdunkels16a7b262004-07-04 21:15:53 +0000138 gtk_main();
adamdunkels408c2b52004-06-06 07:05:40 +0000139
adamdunkels1103ef92003-04-02 09:17:18 +0000140
141 return 0;
142
143 argv = argv;
144 argc = argc;
145}
146/*-----------------------------------------------------------------------------------*/
uid9319536377f32004-02-16 21:27:17 +0000147#include <sys/time.h>
148
adamdunkels16a7b262004-07-04 21:15:53 +0000149clock_time_t
150clock_time(void)
uid9319536377f32004-02-16 21:27:17 +0000151{
152 struct timeval tv;
153 struct timezone tz;
154
155 gettimeofday(&tv, &tz);
156
157 return tv.tv_sec * 1000 + tv.tv_usec / 1000;
158}
159/*-----------------------------------------------------------------------------------*/
adamdunkels408c2b52004-06-06 07:05:40 +0000160
161void nntpc_done(int i) {}
adamdunkels779b9242004-08-11 21:26:22 +0000162
163void log_message(char *m1, char *m2)
164{
165 printf("%s%s\n", m1, m2);
166}