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.
23 #include <appcore-common.h>
28 #include <Elementary.h>
29 #include <notification.h>
31 #include "pts_debug.h"
33 #include <smsc_smart.h>
35 #define PTS_2 "Can not register the printer"
36 #define PTS_17 "Error option"
37 #define PTS_18 "Tap to add printer"
38 #define PTS_19 "Unable to cancel. The current page is already being printed."
40 #define IDS_PRT_1 "Failed to connect Wi-Fi Direct Printer"
41 #define IDS_PRT_2 "USB Printer Connected"
42 #define IDS_PRT_5 "Unable to cancel. The current page is already being printed."
43 #define IDS_PRT_6 "The printer is not connected"
44 #define IDS_PRT_7 "Disconnect USB cable, then reconnect it"
45 #define IDS_PRT_8 "You are not connected to a Wi-Fi network"
46 #define IDS_PRT_9 "The printer is not ready"
47 #define IDS_PRT_10 "Print info error"
48 #define IDS_PRT_11 "Printer is use"
49 #define IDS_PRT_12 "Printing failed"
50 #define IDS_PRT_13 "Unsupported file"
51 #define IDS_PRT_14 "File related error"
52 #define IDS_PRT_15 "The output tray is almost full"
53 #define IDS_PRT_16 "The output tray is full"
54 #define IDS_PRT_17 "Printer supply low"
55 #define IDS_PRT_18 "Printer supply empty"
56 #define IDS_PRT_19 "Device failure"
57 #define IDS_PRT_20 "No ink"
58 #define IDS_PRT_21 "No ink cartridge"
59 #define IDS_PRT_22 "The printer catridge is running low"
60 #define IDS_PRT_23 "Ink cover open"
61 #define IDS_PRT_24 "Ink related error"
62 #define IDS_PRT_25 "The paper tray is empty"
63 #define IDS_PRT_26 "The paper tray is running low"
64 #define IDS_PRT_27 "Paper jam"
65 #define IDS_PRT_28 "The paper size or type is incorrect"
66 #define IDS_PRT_29 "Paper loading error occurred"
67 #define IDS_PRT_30 "Paper related error occurred"
68 #define IDS_PRT_31 "Printer cover open"
69 #define IDS_PRT_32 "Printer hardware error occurred"
70 #define IDS_PRT_33 "Paper level error"
71 #define IDS_PRT_34 "No print head"
72 #define IDS_PRT_35 "Printer related error occurred"
73 #define IDS_PRT_41 "Failed to launch mobileprint"
75 #define IDS_BR_OPT_5X7 "5\"x7\"(13x18cm)"
76 #define IDS_BR_OPT_4X6 "4\"x6\"(10x15cm)"
77 #define IDS_BR_OPT_3_5X5 "3.5\"x5\"(9x13cm)"
78 #define IDS_BR_OPT_WALLET "Wallet(6.4x8.4cm)"
81 #define IDS_PRT_GET_ATTRS_FOR_PRINTERS "Getting printer attributes..."
82 #define IDS_ASEML_POP_GET_ATTRS_FAILED "Failed to get printer attributes"
84 #define IDS_SCRREAD_CANCEL_SEARCHING_PRINTERS "Double tap to cancel searching for printers"
85 #define IDS_SCRREAD_CONFIRM_SELECTED_PRINTER "Press to confirm selected printer"
86 #define IDS_SCRREAD_CANCEL_CONNECT_WIFI "Cancel connect to Wi-Fi network"
87 #define IDS_SCRREAD_SMPOS_SK3_CANCEL "Press to cancel printing"
88 #define IDS_SCRREAD_MORE_OPTIONS "More options"
89 #define IDS_SCRREAD_CANCEL_PRINTING "Double tap to cancel printing"
90 #define IDS_SCRREAD_MENU_INFO "More options"
91 #define IDS_SCRREAD_MENU_CONTEXT "Double click to access options menu"
92 #define IDS_SCRREAD_PRINTERS_LIST_IS_BELOW "Printers list is below"
93 #define IDS_SCRREAD_PRINT_CONTEXT "Double tap to send document to the printer"
94 #define IDS_SCRREAD_PREVIEW_IMAGE_TYPE "Preview of the document to be printed"
95 #define IDS_SCRREAD_PREVIEW_IMAGE_CONTEXT "Print button is below"
96 #define IDS_SCRREAD_EXPANDABLE_LIST_TYPE "Expandable list"
97 #define IDS_SCRREAD_EXPANDABLE_LIST_CONTEXT "Double tap to open list"
98 #define IDS_SCRREAD_SETTINS_ITEM_CONTEXT "Double tap to edit"
99 #define IDS_SCRREAD_PRINTER_ITEM_CONTEXT "Double tap to change selected printer"
101 #define SERVICE_LAUNCH_TYPE "LAUNCH_TYPE"
102 #define SERVICE_JOB_ID "JOB_ID"
103 #define SERVICE_FILES "FILES"
104 #define SERVICE_PAGE_COUNT "PAGE_COUNT"
105 #define LAUNCH_FROM_DUMMY_NOTI "launch_from_dummy_noti"
106 #define LAUNCH_FROM_PROGRESS_NOTI "launch_from_progress_noti"
107 #define SERVICE_PRINT_FILES_COUNT "service_print_files_count"
108 #define SERVICE_PRINT_FILES_CURRENT_INDEX "service_print_files_current_index"
109 #define SERVICE_PRINT_FILES_TYPE "service_print_files_type"
110 #define SERVICE_PRINT_FILES_FOLDER_NAME "service_print_files_folder_name"
111 #define SERVICE_PRINT_FILES_FILES_NAME "service_print_files_files_name"
113 #define ICON_PRINTER "/usr/apps/org.tizen.mobileprint/res/images/pt_default_printer.png"
115 #define UG_MAX_FILED_LEN 64
116 #define COPIES_MAX 99
119 #define MIN(a,b) ((((a)-(b))&0x80000000) >> 31)? (a) : (b)
120 #define PRINTER_LIST_POPUP_W 656
121 #define PRINTER_LIST_POPUP_H 880
122 #define PRINTER_LIST_POPUP_LN_W 720
123 #define PRINTER_LIST_POPUP_LN_H 480
126 #define API __attribute__ ((visibility("default")))
128 #define _EDJ(obj) (Evas_Object *)elm_layout_edje_get(obj)
131 //# define _(str) gettext(str)
135 # define gettext_noop(str) (str)
136 # define N_(str) gettext_noop(str)
140 # define S_(str) dgettext("sys_string", str)
144 # define P_(str) dgettext(PACKAGE, str)
148 # define U_(str) dgettext(UGNAME, str)
152 PTS_SIZE_FIT_TO_PAPER,
162 PTS_SEARCH_INITIAL, // Before launching preview, this printer search is triggered.
163 PTS_SEARCH_IN_PREVIEW, // When USB Printer detected, this printer search is triggered
164 PTS_SEARCH_IN_SETTING, // When ether USB Printer detected or printer search button is presed, this printer search is triggered
165 } pts_printer_search_state_e;
168 char **selected_files; /** selected print files*/
169 int from; /** from print position, the first file equals 0 */
170 int to; /** to print position*/
176 char **request_files;
181 } pts_printing_data_t;
186 notification_h noti_handle;
189 pts_printing_data_t pt_files;
193 } pts_job_spooling_t;
195 typedef void (*pts_printer_selection_done_cb)(void *userdata);
198 Evas_Object *root_win;
199 Evas_Object *main_layout;
201 Evas_Object *printer_layout;
202 Evas_Object *printer_label;
203 Evas_Object *more_btn;
204 Evas_Object *print_btn;
205 Evas_Object *ctxpopup;
211 Evas_Object *wifi_type_popup;
212 Evas_Object *printer_list_popup;
213 Evas_Object *printer_list_popup_box;
214 Evas_Coord printer_list_popup_portrait_height;
215 Evas_Coord printer_list_popup_landscape_height;
216 Evas_Object *no_found_popup;
217 Evas_Object *scaling_popup;
218 Evas_Object *size_popup;
219 Evas_Object *size_popup_box;
220 Evas_Coord size_popup_portrait_height;
221 Evas_Coord size_popup_landscape_height;
222 Evas_Object *custom_popup;
223 Evas_Object *custom_popup_box;
224 Evas_Coord custom_popup_portrait_height;
225 Evas_Coord custom_popup_landscape_height;
227 Evas_Object *progressbar;
228 Evas_Object *progress_layout;
229 Evas_Object *progress_label;
234 Evas_Object *img_layout;
238 Elm_Object_Item *navi_it;
240 /* Print Search Type*/
241 pts_printer_search_state_e print_search_mode;
242 pts_printer_selection_done_cb selection_done_cb;
243 Evas_Object *print_search_popup_parent;
244 void *printer_search_user_data;
246 /* Setting option: Header-item */
247 Elm_Object_Item *printer_item;
248 Elm_Object_Item *header_separator_item;
249 Elm_Object_Item *item_paper_size;
250 Elm_Object_Item *item_paper_copies;
251 Elm_Object_Item *item_paper_quality;
252 Elm_Object_Item *item_paper_type;
253 Elm_Object_Item *item_page_range;
254 Elm_Object_Item *item_grayscale;
255 Elm_Object_Item *footer_separator_item;
257 /* Settings: subitems */
258 Elm_Object_Item **paper_size;
259 Elm_Object_Item *quality[PT_QUALITY_ANY];
260 Elm_Object_Item *paper_type[PT_PAPER_ANY];
261 Elm_Object_Item *color[PT_GRAYSCALE_ANY];
263 /* Setting option: Radio Group Leader */
264 Evas_Object *radio_group_paper_size;
265 Evas_Object *radio_group_paper_quality;
266 Evas_Object *radio_group_paper_type;
267 Evas_Object *radio_group_page_range;
268 Evas_Object *radio_group_grayscale;
270 char *input_file; /* initial input file */
271 pts_printing_data_t pt_files;
273 * wifi, usb, all connection
280 pt_printer_mgr_t *active_printer;
281 pt_printer_mgr_t *select_printer;
284 Eina_List *job_spooling_list;
288 int landscape_toggle;
290 /* whether in process(searching, printing) */
293 pts_image_size_e image_size;
296 double custom_height;
297 double custom_w_ratio;
298 int custom_unit; // 1:cm 2:inch
303 Eina_List *printer_list;
305 pts_core_data_t *ugd;
307 Ecore_Timer *search_err_timer;
311 pts_core_data_t *ugd;
313 pt_print_option_e option; /* pts_print_option_type */
314 int sub_item; /* Individual item. It stores any type of options:
315 pt_paper_size_t, pt_range_t,
316 pt_grayscale_t, pt_quality_t,
320 Elm_Object_Item *item;
321 Evas_Object *radio_btn;
322 Evas_Object *radio_group;
326 * This function let the app create the label
328 * @param[in] parent the pointer to the parent of the label
329 * @param[in] desc the pointer to label text
331 Evas_Object *pts_create_label_btn(Evas_Object *parent, const char *label);
334 * This function let the app create the base layout
336 * @param[in] parent the pointer to the parent of the base layout
337 * @param[in] desc the pointer to group of the base layout
339 Evas_Object *pts_create_base_layout(Evas_Object *parent, const char *group);
342 * This function let the app create the base layout
344 * @param[in] parent the pointer to the parent of the base layout
345 * @param[in] desc the pointer to group of the base layout
347 Evas_Object *pts_create_base_layout_with_conform(Evas_Object *parent, const char *group);
350 * This function let the app create the popup element
352 * @param[in] parent the pointer to the parent of the popup element
353 * @param[in] desc the pointer to description of the popup element
354 * @param[in] timeout the timeout value
356 Evas_Object *pts_create_popup(Evas_Object *parent, const char *desc, double timeout);
357 Evas_Object *pts_create_size_popup(Evas_Object *parent, pts_core_data_t *ugd);
358 Evas_Object *pts_create_scaling_popup(Evas_Object *parent, pts_core_data_t *ugd);
359 Evas_Object *pts_create_wifi_popup(Evas_Object *parent, pts_core_data_t *ugd);
360 void clear_preview_image(pts_core_data_t *ugd);
361 void pts_set_ugd(pts_core_data_t *ugd);
362 pts_core_data_t *pts_get_ugd(void);
365 int _pts_get_rotate_angle(enum appcore_rm rotate_mode);
366 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);
367 void pts_create_print_search_popup(Evas_Object *parent, pts_core_data_t *ugd);
368 Evas_Object *pts_utils_create_layout(Evas_Object *navi_frame);
369 void load_main_view(void *userdata);
371 inline char *_pts_printing_data_get_directory(pts_printing_data_t *data);
372 inline char **_pts_printing_data_get_request_files(pts_printing_data_t *data);
373 inline int _pts_printing_data_get_files_count(pts_printing_data_t *data);
374 inline int _pts_printing_data_get_index(pts_printing_data_t *data);
375 inline char *_pts_printing_data_get_type(pts_printing_data_t *data);
376 Eina_Bool _pts_printing_data_set_directory(const char *directory, pts_printing_data_t *data);
377 Eina_Bool _pts_printing_data_set_request_files(const char **request_files, const int files_count, pts_printing_data_t *data);
378 Eina_Bool _pts_printing_data_set_files_count(const char *num_of_files, pts_printing_data_t *data);
379 Eina_Bool _pts_printing_data_set_index(const char *current_index, pts_printing_data_t *data);
380 Eina_Bool _pts_printing_data_set_type(const char *type, pts_printing_data_t *data);
382 char *pts_parse_protocol(char *addr);
383 int pts_unstandardization(char *name);
385 #endif /* PTS_COMMON_H_ */