adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 1 | /* |
| 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. |
| 14 | * 3. All advertising materials mentioning features or use of this |
| 15 | * software must display the following acknowledgement: |
| 16 | * This product includes software developed by Adam Dunkels. |
| 17 | * 4. The name of the author may not be used to endorse or promote |
| 18 | * products derived from this software without specific prior |
| 19 | * written permission. |
| 20 | * |
| 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
| 22 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 27 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | * |
| 33 | * This file is part of the Contiki desktop environment |
| 34 | * |
adamdunkels | 3cb4de8 | 2003-09-04 19:19:36 +0000 | [diff] [blame] | 35 | * $Id: contiki-main.c,v 1.9 2003/09/04 19:19:36 adamdunkels Exp $ |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 36 | * |
| 37 | */ |
| 38 | |
| 39 | |
| 40 | #include "ctk.h" |
| 41 | #include "ctk-draw.h" |
| 42 | #include "dispatcher.h" |
| 43 | |
adamdunkels | 34bda13 | 2003-04-08 18:20:17 +0000 | [diff] [blame] | 44 | #include "program-handler.h" |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 45 | |
adamdunkels | c8fc230 | 2003-05-28 05:22:39 +0000 | [diff] [blame] | 46 | #include "tapdev-drv.h" |
| 47 | |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 48 | #include "uip_main.h" |
| 49 | #include "uip.h" |
| 50 | #include "uip_arp.h" |
| 51 | |
adamdunkels | 1354b51 | 2003-04-17 20:07:23 +0000 | [diff] [blame] | 52 | #include "about-dsc.h" |
| 53 | #include "netconf-dsc.h" |
| 54 | #include "processes-dsc.h" |
adamdunkels | 12ebc1a | 2003-08-11 22:19:19 +0000 | [diff] [blame] | 55 | #include "calc-dsc.h" |
adamdunkels | 1354b51 | 2003-04-17 20:07:23 +0000 | [diff] [blame] | 56 | |
adamdunkels | 12ebc1a | 2003-08-11 22:19:19 +0000 | [diff] [blame] | 57 | #include "telnet-dsc.h" |
adamdunkels | 1354b51 | 2003-04-17 20:07:23 +0000 | [diff] [blame] | 58 | #include "www-dsc.h" |
adamdunkels | c8fc230 | 2003-05-28 05:22:39 +0000 | [diff] [blame] | 59 | #include "webserver-dsc.h" |
adamdunkels | 1354b51 | 2003-04-17 20:07:23 +0000 | [diff] [blame] | 60 | |
adamdunkels | 779035a | 2003-09-01 22:24:52 +0000 | [diff] [blame] | 61 | /*#include "presenter-dsc.h"*/ |
adamdunkels | 12ebc1a | 2003-08-11 22:19:19 +0000 | [diff] [blame] | 62 | |
| 63 | #include "wget-dsc.h" |
| 64 | |
| 65 | #include "email-dsc.h" |
adamdunkels | c8d5189 | 2003-08-31 22:20:52 +0000 | [diff] [blame] | 66 | /*#include "maze-dsc.h"*/ |
| 67 | |
| 68 | #include "telnetd-dsc.h" |
| 69 | |
| 70 | #include "resolv.h" |
| 71 | #include "ctk-vncserver.h" |
| 72 | |
| 73 | #include <gdk/gdktypes.h> |
| 74 | #include <gtk/gtk.h> |
| 75 | |
| 76 | |
adamdunkels | 12ebc1a | 2003-08-11 22:19:19 +0000 | [diff] [blame] | 77 | |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 78 | static gint |
| 79 | idle_callback(gpointer data) |
| 80 | { |
adamdunkels | c8d5189 | 2003-08-31 22:20:52 +0000 | [diff] [blame] | 81 | dispatcher_process_signal(); |
| 82 | dispatcher_process_idle(); |
| 83 | |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 84 | return TRUE; |
| 85 | } |
| 86 | /*-----------------------------------------------------------------------------------*/ |
| 87 | int |
| 88 | main(int argc, char **argv) |
| 89 | { |
adamdunkels | 1354b51 | 2003-04-17 20:07:23 +0000 | [diff] [blame] | 90 | u16_t addr[2]; |
| 91 | |
adamdunkels | c8d5189 | 2003-08-31 22:20:52 +0000 | [diff] [blame] | 92 | /* ek_init();*/ |
adamdunkels | 12ebc1a | 2003-08-11 22:19:19 +0000 | [diff] [blame] | 93 | dispatcher_init(); |
| 94 | |
| 95 | |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 96 | uip_init(); |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 97 | resolv_init(); |
| 98 | |
adamdunkels | 1354b51 | 2003-04-17 20:07:23 +0000 | [diff] [blame] | 99 | /* XXX: just for making it easier to test. */ |
| 100 | uip_ipaddr(addr, 192,168,1,2); |
| 101 | uip_sethostaddr(addr); |
| 102 | |
| 103 | uip_ipaddr(addr, 192,168,1,1); |
| 104 | uip_setdraddr(addr); |
| 105 | |
| 106 | uip_ipaddr(addr, 255,255,255,0); |
| 107 | uip_setnetmask(addr); |
| 108 | |
| 109 | |
adamdunkels | c8fc230 | 2003-05-28 05:22:39 +0000 | [diff] [blame] | 110 | tapdev_drv_init(); |
adamdunkels | c8d5189 | 2003-08-31 22:20:52 +0000 | [diff] [blame] | 111 | |
| 112 | #if WITH_CTKVNC |
| 113 | ctk_init(); |
| 114 | ctk_vncserver_init(NULL); |
| 115 | #else |
adamdunkels | f695969 | 2003-04-15 21:19:47 +0000 | [diff] [blame] | 116 | ctk_gtksim_init(); |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 117 | ctk_init(); |
adamdunkels | c8d5189 | 2003-08-31 22:20:52 +0000 | [diff] [blame] | 118 | #endif |
adamdunkels | 1354b51 | 2003-04-17 20:07:23 +0000 | [diff] [blame] | 119 | |
adamdunkels | 34bda13 | 2003-04-08 18:20:17 +0000 | [diff] [blame] | 120 | program_handler_init(); |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 121 | |
| 122 | gtk_timeout_add(20, idle_callback, NULL); |
adamdunkels | 1354b51 | 2003-04-17 20:07:23 +0000 | [diff] [blame] | 123 | |
| 124 | /* vnc_init();*/ |
| 125 | program_handler_add(&about_dsc, "About", 1); |
| 126 | program_handler_add(&netconf_dsc, "Network setup", 1); |
| 127 | program_handler_add(&processes_dsc, "Processes", 0); |
| 128 | |
| 129 | program_handler_add(&www_dsc, "Web browser", 1); |
adamdunkels | 12ebc1a | 2003-08-11 22:19:19 +0000 | [diff] [blame] | 130 | |
adamdunkels | c8fc230 | 2003-05-28 05:22:39 +0000 | [diff] [blame] | 131 | program_handler_add(&webserver_dsc, "Web server", 1); |
adamdunkels | 12ebc1a | 2003-08-11 22:19:19 +0000 | [diff] [blame] | 132 | program_handler_add(&telnet_dsc, "Telnet", 1); |
| 133 | |
| 134 | program_handler_add(&calc_dsc, "Calculator", 0); |
| 135 | |
| 136 | /* program_handler_add(&presenter_dsc, "Presenter", 1);*/ |
| 137 | |
| 138 | program_handler_add(&email_dsc, "E-mail", 1); |
adamdunkels | c8d5189 | 2003-08-31 22:20:52 +0000 | [diff] [blame] | 139 | |
| 140 | program_handler_add(&telnetd_dsc, "Telnet daemon", 1); |
| 141 | /* program_handler_add(&maze_dsc, "3D maze", 1);*/ |
adamdunkels | 12ebc1a | 2003-08-11 22:19:19 +0000 | [diff] [blame] | 142 | |
| 143 | /*program_handler_add(&wget_dsc, "Web downloader", 1);*/ |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 144 | |
adamdunkels | 12ebc1a | 2003-08-11 22:19:19 +0000 | [diff] [blame] | 145 | /* ctk_redraw();*/ |
adamdunkels | 3cb4de8 | 2003-09-04 19:19:36 +0000 | [diff] [blame] | 146 | /* maze_init();*/ |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 147 | gtk_main(); |
| 148 | |
| 149 | return 0; |
| 150 | |
| 151 | argv = argv; |
| 152 | argc = argc; |
| 153 | } |
| 154 | /*-----------------------------------------------------------------------------------*/ |