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. |
adamdunkels | 408c2b5 | 2004-06-06 07:05:40 +0000 | [diff] [blame] | 14 | * 3. The name of the author may not be used to endorse or promote |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 15 | * 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 | * |
adamdunkels | 22abf98 | 2004-09-01 20:34:06 +0000 | [diff] [blame] | 32 | * $Id: contiki-main.c,v 1.14 2004/09/01 20:34:18 adamdunkels Exp $ |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 33 | * |
| 34 | */ |
| 35 | |
adamdunkels | 16a7b26 | 2004-07-04 21:15:53 +0000 | [diff] [blame] | 36 | #include "ek.h" |
| 37 | #include "clock.h" |
adamdunkels | c8d5189 | 2003-08-31 22:20:52 +0000 | [diff] [blame] | 38 | |
| 39 | #include <gdk/gdktypes.h> |
| 40 | #include <gtk/gtk.h> |
| 41 | |
adamdunkels | 16a7b26 | 2004-07-04 21:15:53 +0000 | [diff] [blame] | 42 | #include "uip.h" |
| 43 | #include "ctk.h" |
adamdunkels | 408c2b5 | 2004-06-06 07:05:40 +0000 | [diff] [blame] | 44 | |
adamdunkels | 779b924 | 2004-08-11 21:26:22 +0000 | [diff] [blame] | 45 | #include "ctk-vncserver.h" |
| 46 | #include "ctk-termtelnet.h" |
| 47 | |
| 48 | #include "cfs-posix.h" |
| 49 | |
adamdunkels | 16a7b26 | 2004-07-04 21:15:53 +0000 | [diff] [blame] | 50 | #include "uip-fw.h" |
adamdunkels | 408c2b5 | 2004-06-06 07:05:40 +0000 | [diff] [blame] | 51 | |
adamdunkels | 16a7b26 | 2004-07-04 21:15:53 +0000 | [diff] [blame] | 52 | #include "about-dsc.h" |
| 53 | #include "calc-dsc.h" |
adamdunkels | 779b924 | 2004-08-11 21:26:22 +0000 | [diff] [blame] | 54 | #include "editor-dsc.h" |
adamdunkels | 16a7b26 | 2004-07-04 21:15:53 +0000 | [diff] [blame] | 55 | #include "email-dsc.h" |
adamdunkels | 779b924 | 2004-08-11 21:26:22 +0000 | [diff] [blame] | 56 | #include "ftp-dsc.h" |
adamdunkels | 22abf98 | 2004-09-01 20:34:06 +0000 | [diff] [blame] | 57 | #include "irc-dsc.h" |
adamdunkels | 16a7b26 | 2004-07-04 21:15:53 +0000 | [diff] [blame] | 58 | #include "netconf-dsc.h" |
| 59 | #include "processes-dsc.h" |
| 60 | #include "shell-dsc.h" |
| 61 | #include "www-dsc.h" |
adamdunkels | 408c2b5 | 2004-06-06 07:05:40 +0000 | [diff] [blame] | 62 | |
adamdunkels | 408c2b5 | 2004-06-06 07:05:40 +0000 | [diff] [blame] | 63 | |
adamdunkels | 408c2b5 | 2004-06-06 07:05:40 +0000 | [diff] [blame] | 64 | |
| 65 | void tapdev_send(void); |
| 66 | static struct uip_fw_netif tapif = |
| 67 | {UIP_FW_NETIF(0,0,0,0, 0,0,0,0, tapdev_send)}; |
adamdunkels | c8d5189 | 2003-08-31 22:20:52 +0000 | [diff] [blame] | 68 | |
adamdunkels | 12ebc1a | 2003-08-11 22:19:19 +0000 | [diff] [blame] | 69 | |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 70 | static gint |
| 71 | idle_callback(gpointer data) |
| 72 | { |
adamdunkels | 408c2b5 | 2004-06-06 07:05:40 +0000 | [diff] [blame] | 73 | |
adamdunkels | 16a7b26 | 2004-07-04 21:15:53 +0000 | [diff] [blame] | 74 | ek_run(); |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 75 | return TRUE; |
| 76 | } |
| 77 | /*-----------------------------------------------------------------------------------*/ |
| 78 | int |
| 79 | main(int argc, char **argv) |
| 80 | { |
adamdunkels | 1354b51 | 2003-04-17 20:07:23 +0000 | [diff] [blame] | 81 | u16_t addr[2]; |
adamdunkels | 408c2b5 | 2004-06-06 07:05:40 +0000 | [diff] [blame] | 82 | |
adamdunkels | 779b924 | 2004-08-11 21:26:22 +0000 | [diff] [blame] | 83 | /* html_test();*/ |
| 84 | |
| 85 | gtk_init(&argc, &argv); |
| 86 | |
| 87 | ek_init(); |
| 88 | |
| 89 | tcpip_init(NULL); |
| 90 | |
adamdunkels | 16a7b26 | 2004-07-04 21:15:53 +0000 | [diff] [blame] | 91 | ctk_gtksim_service_init(NULL); |
| 92 | ctk_init(); |
| 93 | |
adamdunkels | 22abf98 | 2004-09-01 20:34:06 +0000 | [diff] [blame] | 94 | /* ctk_vncserver_init(NULL); */ |
adamdunkels | 779b924 | 2004-08-11 21:26:22 +0000 | [diff] [blame] | 95 | /* ctk_termtelnet_init(NULL);*/ |
| 96 | |
adamdunkels | 16a7b26 | 2004-07-04 21:15:53 +0000 | [diff] [blame] | 97 | 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); |
adamdunkels | 12ebc1a | 2003-08-11 22:19:19 +0000 | [diff] [blame] | 109 | |
adamdunkels | 16a7b26 | 2004-07-04 21:15:53 +0000 | [diff] [blame] | 110 | 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); |
adamdunkels | 779b924 | 2004-08-11 21:26:22 +0000 | [diff] [blame] | 121 | program_handler_add(&ftp_dsc, "FTP client", 1); |
| 122 | program_handler_add(&editor_dsc, "Editor", 1); |
adamdunkels | 16a7b26 | 2004-07-04 21:15:53 +0000 | [diff] [blame] | 123 | 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); |
adamdunkels | 22abf98 | 2004-09-01 20:34:06 +0000 | [diff] [blame] | 128 | |
| 129 | program_handler_add(&irc_dsc, "IRC", 1); |
adamdunkels | 16a7b26 | 2004-07-04 21:15:53 +0000 | [diff] [blame] | 130 | |
| 131 | gtk_timeout_add(20, idle_callback, NULL); |
adamdunkels | 779b924 | 2004-08-11 21:26:22 +0000 | [diff] [blame] | 132 | |
| 133 | |
| 134 | cfs_posix_init(NULL); |
| 135 | |
| 136 | /* sock_httpd_init(NULL);*/ |
| 137 | |
adamdunkels | 16a7b26 | 2004-07-04 21:15:53 +0000 | [diff] [blame] | 138 | gtk_main(); |
adamdunkels | 408c2b5 | 2004-06-06 07:05:40 +0000 | [diff] [blame] | 139 | |
adamdunkels | 1103ef9 | 2003-04-02 09:17:18 +0000 | [diff] [blame] | 140 | |
| 141 | return 0; |
| 142 | |
| 143 | argv = argv; |
| 144 | argc = argc; |
| 145 | } |
| 146 | /*-----------------------------------------------------------------------------------*/ |
uid93195 | 36377f3 | 2004-02-16 21:27:17 +0000 | [diff] [blame] | 147 | #include <sys/time.h> |
| 148 | |
adamdunkels | 16a7b26 | 2004-07-04 21:15:53 +0000 | [diff] [blame] | 149 | clock_time_t |
| 150 | clock_time(void) |
uid93195 | 36377f3 | 2004-02-16 21:27:17 +0000 | [diff] [blame] | 151 | { |
| 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 | /*-----------------------------------------------------------------------------------*/ |
adamdunkels | 408c2b5 | 2004-06-06 07:05:40 +0000 | [diff] [blame] | 160 | |
| 161 | void nntpc_done(int i) {} |
adamdunkels | 779b924 | 2004-08-11 21:26:22 +0000 | [diff] [blame] | 162 | |
| 163 | void log_message(char *m1, char *m2) |
| 164 | { |
| 165 | printf("%s%s\n", m1, m2); |
| 166 | } |