4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://floralicense.org/license/
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
26 #include <Elementary.h>
27 #include <notification.h>
29 #include "pts_debug.h"
31 #include "preview_engine.h" /* TODO: move to preview widget */
33 #define PTS_2 "Can not register the printer"
34 #define PTS_17 "Error option"
35 #define PTS_18 "Tap to add printer"
36 #define PTS_19 "Unable to cancel. The current page is already being printed."
38 #define IDS_PRT_1 "Failed to connect Wi-Fi Direct Printer"
39 #define IDS_PRT_2 "USB Printer Connected"
40 #define IDS_PRT_5 "Unable to cancel. The current page is already being printed."
41 #define IDS_PRT_6 "The printer is not connected"
42 #define IDS_PRT_7 "Disconnect USB cable, then reconnect it"
43 #define IDS_PRT_8 "You are not connected to a Wi-Fi network"
44 #define IDS_PRT_9 "The printer is not ready"
45 #define IDS_PRT_10 "Print info error"
46 #define IDS_PRT_11 "Printer is use"
47 #define IDS_PRT_12 "Printing failed"
48 #define IDS_PRT_13 "Unsupported file"
49 #define IDS_PRT_14 "File related error"
50 #define IDS_PRT_15 "The output tray is almost full"
51 #define IDS_PRT_16 "The output tray is full"
52 #define IDS_PRT_17 "Printer supply low"
53 #define IDS_PRT_18 "Printer supply empty"
54 #define IDS_PRT_19 "Device failure"
55 #define IDS_PRT_20 "No ink"
56 #define IDS_PRT_21 "No ink cartridge"
57 #define IDS_PRT_22 "The printer catridge is running low"
58 #define IDS_PRT_23 "Ink cover open"
59 #define IDS_PRT_24 "Ink related error"
60 #define IDS_PRT_25 "The paper tray is empty"
61 #define IDS_PRT_26 "The paper tray is running low"
62 #define IDS_PRT_27 "Paper jam"
63 #define IDS_PRT_28 "The paper size or type is incorrect"
64 #define IDS_PRT_29 "Paper loading error occurred"
65 #define IDS_PRT_30 "Paper related error occurred"
66 #define IDS_PRT_31 "Printer cover open"
67 #define IDS_PRT_32 "Printer hardware error occurred"
68 #define IDS_PRT_33 "Paper level error"
69 #define IDS_PRT_34 "No print head"
70 #define IDS_PRT_35 "Printer related error occurred"
72 #define IDS_BR_OPT_5X7 "5\"x7\"(13x18cm)"
73 #define IDS_BR_OPT_4X6 "4\"x6\"(10x15cm)"
74 #define IDS_BR_OPT_3_5X5 "3.5\"x5\"(9x13cm)"
75 #define IDS_BR_OPT_WALLET "Wallet(6.4x8.4cm)"
77 #define SERVICE_LAUNCH_TYPE "LAUNCH_TYPE"
78 #define SERVICE_JOB_ID "JOB_ID"
79 #define SERVICE_FILES "FILES"
80 #define SERVICE_PAGE_COUNT "PAGE_COUNT"
81 #define LAUNCH_FROM_DUMMY_NOTI "launch_from_dummy_noti"
82 #define LAUNCH_FROM_PROGRESS_NOTI "launch_from_progress_noti"
83 #define SERVICE_PRINT_FILES_COUNT "service_print_files_count"
84 #define SERVICE_PRINT_FILES_CURRENT_INDEX "service_print_files_current_index"
85 #define SERVICE_PRINT_FILES_TYPE "service_print_files_type"
86 #define SERVICE_PRINT_FILES_FOLDER_NAME "service_print_files_folder_name"
87 #define SERVICE_PRINT_FILES_FILES_NAME "service_print_files_files_name"
89 #define ICON_PRINTER "/opt/usr/apps/org.tizen.mobileprint/res/images/pt_default_printer.png"
91 #define UG_MAX_FILED_LEN 64
95 #define API __attribute__ ((visibility("default")))
97 #define _EDJ(obj) (Evas_Object *)elm_layout_edje_get(obj)
100 //# define _(str) gettext(str)
104 # define gettext_noop(str) (str)
105 # define N_(str) gettext_noop(str)
109 # define S_(str) dgettext("sys_string", str)
113 # define P_(str) dgettext(PACKAGE, str)
117 # define U_(str) dgettext(UGNAME, str)
121 PTS_SIZE_FIT_TO_PAPER,
131 PTS_SEARCH_INITIAL, // Before launching preview, this printer search is triggered.
132 PTS_SEARCH_IN_PREVIEW, // When USB Printer detected, this printer search is triggered
133 PTS_SEARCH_IN_SETTING, // When ether USB Printer detected or printer search button is presed, this printer search is triggered
134 } pts_printer_search_state_e;
137 char **selected_files; /** selected print files*/
138 int from; /** from print position, the first file equals 0 */
139 int to; /** to print position*/
145 char **request_files;
150 } pts_printing_data_t;
155 notification_h noti_handle;
158 pts_printing_data_t pt_files;
161 } pts_job_spooling_t;
163 typedef void (*pts_printer_selection_done_cb)(void *userdata);
166 Evas_Object *root_win;
167 Evas_Object *main_win;
169 Evas_Object *printer_layout;
170 Evas_Object *printer_label;
171 Evas_Object *more_btn;
172 Evas_Object *print_btn;
173 Evas_Object *ctxpopup;
179 Evas_Object *wifi_type_popup;
180 Evas_Object *printer_list_popup;
181 Evas_Object *no_found_popup;
182 Evas_Object *scaling_popup;
183 Evas_Object *size_popup;
184 Evas_Object *size_popup_box;
185 Evas_Coord size_popup_portrait_height;
186 Evas_Coord size_popup_landscape_height;
187 Evas_Object *custom_popup;
188 Evas_Object *custom_popup_box;
189 Evas_Coord custom_popup_portrait_height;
190 Evas_Coord custom_popup_landscape_height;
192 Evas_Object *progressbar;
193 Evas_Object *progress_layout;
194 Evas_Object *progress_label;
199 Evas_Object *img_layout;
203 Elm_Object_Item *navi_it;
205 /* Print Search Type*/
206 pts_printer_search_state_e print_search_mode;
207 pts_printer_selection_done_cb selection_done_cb;
208 Evas_Object *print_search_popup_parent;
209 void *printer_search_user_data;
211 /* Setting option: Header-item */
212 Elm_Object_Item *printer_item;
213 Elm_Object_Item *header_separator_item;
214 Elm_Object_Item *item_paper_size;
215 Elm_Object_Item *item_paper_copies;
216 Elm_Object_Item *item_paper_quality;
217 Elm_Object_Item *item_paper_type;
218 Elm_Object_Item *item_page_range;
219 Elm_Object_Item *item_grayscale;
220 Elm_Object_Item *footer_separator_item;
222 /* Settings: subitems */
223 Elm_Object_Item **paper_size;
224 Elm_Object_Item *quality[PT_QUALITY_ANY];
225 Elm_Object_Item *paper_type[PT_PAPER_ANY];
226 Elm_Object_Item *color[PT_GRAYSCALE_ANY];
228 /* Setting option: Radio Group Leader */
229 Evas_Object *radio_group_paper_size;
230 Evas_Object *radio_group_paper_quality;
231 Evas_Object *radio_group_paper_type;
232 Evas_Object *radio_group_page_range;
233 Evas_Object *radio_group_grayscale;
235 char *input_file; /* initial input file */
236 pts_printing_data_t pt_files;
238 * wifi, usb, all connection
245 pt_printer_mgr_t *active_printer;
246 pt_printer_mgr_t *select_printer;
249 Eina_List *job_spooling_list;
251 Evas_Object *preview_img;
252 Evas_Object *loading_animation;
254 int landscape_toggle;
256 /* whether in process(searching, printing) */
259 struct preview_engine engine; /* TODO: move to widget data */
261 pts_image_size_e image_size;
264 double custom_height;
265 double custom_w_ratio;
266 int custom_unit; // 1:cm 2:inch
271 Eina_List *printer_list;
273 pts_core_data_t *ugd;
275 Ecore_Timer *search_err_timer;
279 pts_core_data_t *ugd;
281 pt_print_option_e option; /* pts_print_option_type */
282 int sub_item; /* Individual item. It stores any type of options:
283 pt_paper_size_t, pt_range_t,
284 pt_grayscale_t, pt_quality_t,
288 Elm_Object_Item *item;
289 Evas_Object *radio_btn;
290 Evas_Object *radio_group;
294 * This function let the app create the label
296 * @param[in] parent the pointer to the parent of the label
297 * @param[in] desc the pointer to label text
299 Evas_Object *pts_create_label_btn(Evas_Object *parent, const char *label);
302 * This function let the app create the base layout
304 * @param[in] parent the pointer to the parent of the base layout
305 * @param[in] desc the pointer to group of the base layout
307 Evas_Object *pts_create_base_layout(Evas_Object *parent, const char *group);
310 * This function let the app create the popup element
312 * @param[in] parent the pointer to the parent of the popup element
313 * @param[in] desc the pointer to description of the popup element
314 * @param[in] timeout the timeout value
316 Evas_Object *pts_create_popup(Evas_Object *parent, const char *desc, double timeout);
317 Evas_Object *pts_create_size_popup(Evas_Object *parent, pts_core_data_t *ugd);
318 Evas_Object *pts_create_scaling_popup(Evas_Object *parent, pts_core_data_t *ugd);
319 Evas_Object *pts_create_wifi_popup(Evas_Object *parent, pts_core_data_t *ugd);
320 void clear_preview_image(pts_core_data_t *ugd);
321 void pts_set_ugd(pts_core_data_t *ugd);
322 pts_core_data_t *pts_get_ugd(void);
326 void pts_search_printer(pts_core_data_t *ugd, Evas_Object *parent, pts_printer_search_state_e search_mode, pts_printer_selection_done_cb cb, void *userdata);
327 void pts_create_print_search_popup(Evas_Object *parent, pts_core_data_t *ugd);
328 Evas_Object *pts_utils_create_layout(Evas_Object *navi_frame);
329 void load_main_view(void *userdata);
331 inline char *_pts_printing_data_get_directory(pts_printing_data_t *data);
332 inline char **_pts_printing_data_get_request_files(pts_printing_data_t *data);
333 inline int _pts_printing_data_get_files_count(pts_printing_data_t *data);
334 inline int _pts_printing_data_get_index(pts_printing_data_t *data);
335 inline char *_pts_printing_data_get_type(pts_printing_data_t *data);
336 Eina_Bool _pts_printing_data_set_directory(const char *directory, pts_printing_data_t *data);
337 Eina_Bool _pts_printing_data_set_request_files(const char **request_files, const int files_count, pts_printing_data_t *data);
338 Eina_Bool _pts_printing_data_set_files_count(const char *num_of_files, pts_printing_data_t *data);
339 Eina_Bool _pts_printing_data_set_index(const char *current_index, pts_printing_data_t *data);
340 Eina_Bool _pts_printing_data_set_type(const char *type, pts_printing_data_t *data);
342 char* pts_parse_protocol(char *addr);
343 int pts_unstandardization(char *name);
345 #endif /* PTS_COMMON_H_ */