19 static device_status_t device_open(const char *devname,
24 case DEVICE_TYPE_SUUNTO_SOLUTION:
25 return suunto_solution_device_open(device, devname);
27 case DEVICE_TYPE_SUUNTO_EON:
28 return suunto_eon_device_open(device, devname);
30 case DEVICE_TYPE_SUUNTO_VYPER:
31 return suunto_vyper_device_open(device, devname);
33 case DEVICE_TYPE_SUUNTO_VYPER2:
34 return suunto_vyper2_device_open(device, devname);
36 case DEVICE_TYPE_SUUNTO_D9:
37 return suunto_d9_device_open(device, devname);
39 case DEVICE_TYPE_UWATEC_ALADIN:
40 return uwatec_aladin_device_open(device, devname);
42 case DEVICE_TYPE_UWATEC_MEMOMOUSE:
43 return uwatec_memomouse_device_open(device, devname);
45 case DEVICE_TYPE_UWATEC_SMART:
46 return uwatec_smart_device_open(device);
48 case DEVICE_TYPE_REEFNET_SENSUS:
49 return reefnet_sensus_device_open(device, devname);
51 case DEVICE_TYPE_REEFNET_SENSUSPRO:
52 return reefnet_sensuspro_device_open(device, devname);
54 case DEVICE_TYPE_REEFNET_SENSUSULTRA:
55 return reefnet_sensusultra_device_open(device, devname);
57 case DEVICE_TYPE_OCEANIC_VTPRO:
58 return oceanic_vtpro_device_open(device, devname);
60 case DEVICE_TYPE_OCEANIC_VEO250:
61 return oceanic_veo250_device_open(device, devname);
63 case DEVICE_TYPE_OCEANIC_ATOM2:
64 return oceanic_atom2_device_open(device, devname);
66 case DEVICE_TYPE_MARES_NEMO:
67 return mares_nemo_device_open(device, devname);
69 case DEVICE_TYPE_MARES_PUCK:
70 return mares_puck_device_open(device, devname);
72 case DEVICE_TYPE_MARES_ICONHD:
73 return mares_iconhd_device_open(device, devname);
75 case DEVICE_TYPE_HW_OSTC:
76 return hw_ostc_device_open(device, devname);
78 case DEVICE_TYPE_CRESSI_EDY:
79 return cressi_edy_device_open(device, devname);
81 case DEVICE_TYPE_ZEAGLE_N2ITION3:
82 return zeagle_n2ition3_device_open(device, devname);
84 case DEVICE_TYPE_ATOMICS_COBALT:
85 return atomics_cobalt_device_open(device);
88 return DEVICE_STATUS_ERROR;
92 static void do_import(const char *computer, device_type_t type)
94 /* FIXME! Needs user input! */
95 const char *devname = "/dev/ttyUSB0";
96 device_t *device = NULL;
99 rc = device_open(devname, type, &device);
100 printf("rc=%d\n", rc);
101 if (rc != DEVICE_STATUS_SUCCESS)
106 * Taken from 'example.c' in libdivecomputer.
108 * I really wish there was some way to just have
109 * libdivecomputer tell us what devices it supports,
110 * rather than have the application have to know..
116 { "Suunto Solution", DEVICE_TYPE_SUUNTO_SOLUTION },
117 { "Suunto Eon", DEVICE_TYPE_SUUNTO_EON },
118 { "Suunto Vyper", DEVICE_TYPE_SUUNTO_VYPER },
119 { "Suunto Vyper Air", DEVICE_TYPE_SUUNTO_VYPER2 },
120 { "Suunto D9", DEVICE_TYPE_SUUNTO_D9 },
121 { "Uwatec Aladin", DEVICE_TYPE_UWATEC_ALADIN },
122 { "Uwatec Memo Mouse", DEVICE_TYPE_UWATEC_MEMOMOUSE },
123 { "Uwatec Smart", DEVICE_TYPE_UWATEC_SMART },
124 { "ReefNet Sensus", DEVICE_TYPE_REEFNET_SENSUS },
125 { "ReefNet Sensus Pro", DEVICE_TYPE_REEFNET_SENSUSPRO },
126 { "ReefNet Sensus Ultra",DEVICE_TYPE_REEFNET_SENSUSULTRA },
127 { "Oceanic VT Pro", DEVICE_TYPE_OCEANIC_VTPRO },
128 { "Oceanic Veo250", DEVICE_TYPE_OCEANIC_VEO250 },
129 { "Oceanic Atom 2", DEVICE_TYPE_OCEANIC_ATOM2 },
130 { "Mares Nemo", DEVICE_TYPE_MARES_NEMO },
131 { "Mares Puck", DEVICE_TYPE_MARES_PUCK },
132 { "Mares Icon HD", DEVICE_TYPE_MARES_ICONHD },
133 { "OSTC", DEVICE_TYPE_HW_OSTC },
134 { "Cressi Edy", DEVICE_TYPE_CRESSI_EDY },
135 { "Zeagle N2iTiON 3", DEVICE_TYPE_ZEAGLE_N2ITION3 },
136 { "Atomics Cobalt", DEVICE_TYPE_ATOMICS_COBALT },
140 static void fill_computer_list(GtkListStore *store)
143 struct device_list *list = device_list;
145 for (list = device_list ; list->name ; list++) {
146 gtk_list_store_append(store, &iter);
147 gtk_list_store_set(store, &iter,
154 static GtkComboBox *dive_computer_selector(GtkWidget *dialog)
156 GtkWidget *hbox, *combo_box;
158 GtkCellRenderer *renderer;
160 hbox = gtk_hbox_new(FALSE, 6);
161 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
163 model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
164 fill_computer_list(model);
166 combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(model));
167 gtk_box_pack_start(GTK_BOX(hbox), combo_box, FALSE, TRUE, 3);
169 renderer = gtk_cell_renderer_text_new();
170 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_box), renderer, TRUE);
171 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box), renderer, "text", 0, NULL);
173 return GTK_COMBO_BOX(combo_box);
176 void import_dialog(GtkWidget *w, gpointer data)
180 GtkComboBox *computer;
182 dialog = gtk_dialog_new_with_buttons("Import from dive computer",
183 GTK_WINDOW(main_window),
184 GTK_DIALOG_DESTROY_WITH_PARENT,
185 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
186 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
189 computer = dive_computer_selector(dialog);
191 gtk_widget_show_all(dialog);
192 result = gtk_dialog_run(GTK_DIALOG(dialog));
198 case GTK_RESPONSE_ACCEPT:
199 if (!gtk_combo_box_get_active_iter(computer, &iter))
201 model = gtk_combo_box_get_model(computer);
202 gtk_tree_model_get(model, &iter,
206 do_import(comp, type);
211 gtk_widget_destroy(dialog);