4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.1 (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.
20 #ifndef __PRINT_SERVICE_API_H__
21 #define __PRINT_SERVICE_API_H__
24 #define API __attribute__ ((visibility("default")))
28 #include <eina_list.h>
29 #define PT_MAX_LENGTH 512
31 typedef enum _pt_err_e {
32 PT_ERR_NONE = 0, /** success */
33 PT_ERR_FAIL, /** operate fail */
34 PT_ERR_INVALID_PARAM, /** invalid parameter */
35 PT_ERR_NO_MEMORY, /** no memory */
36 PT_ERR_NOT_NETWORK_ACCESS, /** network is not available*/
37 PT_ERR_NOT_USB_ACCESS, /** USB is not available */
38 PT_ERR_NO_DEFAULT_PRINTER, /** no default printer */
39 PT_ERR_SET_OPTION_FAIL, /** option is not fit for the printer */
40 PT_ERR_INVALID_USER_CB, /** not USB access */
41 PT_ERR_UNSUPPORTED, /** unsupported */
42 PT_ERR_UNKNOWN, /** unknown error */
45 typedef enum _pt_connection_type_e {
46 PT_CONNECTION_USB =0x01, /** usb mode*/
47 PT_CONNECTION_WIFI =0x02, /** wifi mode */
48 PT_CONNECTION_WIFI_DIRECT=0x04, /** wifi direct mode */
49 } pt_connection_type_e;
51 typedef enum _pt_duplex_e {
59 typedef enum _pt_collate_e {
64 typedef enum _pt_paper_size_e {
65 PT_PAPER_A4 = 0, /** A4: 210.0 mm x 297.0 mm */
66 PT_PAPER_L, /** L : 89.0 mm x 127.0 mm */
67 PT_PAPER_2L, /** 2L: 127.0 mm x 178.0 mm */
68 PT_PAPER_HAGAKI_POSTCARD, /** Hagaki Postcard: 100.0 mm x 148.0 mm */
69 PT_PAPER_BUISNESSCARD, /** Buisness card: 54.0 mm x 85.6 mm */
70 PT_PAPER_4X6, /** 4" x 6": 101.6 mm x 152.4 mm */
71 PT_PAPER_8X10, /** 8" x 10": 203.2 mm x 254.0 mm */
72 PT_PAPER_LETTER, /** Letter: 216.0 mm x 279.4 mm */
73 PT_PAPER_11X17, /** 11" x 17": 279.4 mm x 431.8 mm */
77 typedef enum _pt_scaling_e {
78 PT_SCALING_FIT_TO_PAGE = 0, /** Fit to page */
79 // PT_SCALING_ORIGINAL_SIZE, /** Original image size 100% */
80 PT_SCALING_2_PAGES, /** 2 pages in 1 sheet */
81 PT_SCALING_4_PAGES /** 4 pages in 1 sheet */
82 // PT_SCALING_8_PAGES, /** 8 pages in 1 sheet */
85 typedef enum _pt_image_size_option_e {
86 PT_SIZE_FIT_TO_PAPER = 0,
93 } pt_image_size_option_e;
95 typedef enum _pt_orientation_e {
96 //PT_ORIENTATION_AUTO = 0, /** Auto rotation */
97 PT_ORIENTATION_PORTRAIT, /** Portrait mode */
98 PT_ORIENTATION_LANDSCAPE, /** Landscape mode */
101 typedef enum _pt_paper_e {
102 PT_PAPER_NORMAL = 0, /** Normal paper */
103 PT_PAPER_GLOSSY, /** Glossy paper */
104 PT_PAPER_PHOTO, /** Photographic paper */
105 PT_PAPER_ANY, /** Any kind of paper - doesn't matter */
109 typedef enum _pt_quality_e {
110 PT_QUALITY_DRAFT = 0, /** Draft print */
111 PT_QUALITY_STANDARD, /** Standard */
112 PT_QUALITY_HIGH, /** High quality print */
113 PT_QUALITY_ANY, /** Any quality - doesn't matter */
117 typedef enum _pt_range_e {
118 PT_RANGE_ALL = 0, /** Print all pages */
119 PT_RANGE_CURRENT, /** Print current page */
123 typedef enum _pt_grayscale_e {
124 PT_GRAYSCALE_GRAYSCALE = 0, /** Grayscale print */
125 PT_GRAYSCALE_COLOUR, /** Coloured print */
126 // PT_GRAYSCALE_BLACKNWHITE, /** Black & White print */
127 PT_GRAYSCALE_ANY, /** Color Or Grayscale - doesn't matter */
131 typedef enum _pt_printer_state_e {
132 PT_PRINTER_IDLE = 0, /** printer is in idle mode */
133 PT_PRINTER_BUSY, /** printer is busy for printing */
134 PT_PRINTER_STOPPED, /** printer has stopped printing */
135 PT_PRINTER_OFFLINE, /** printer offline */
136 } pt_printer_state_e;
138 typedef enum _pt_job_state_e {
139 PT_JOB_ERROR = -1, /** invalid job status */
140 PT_JOB_PENDING = 3, /** waiting to be printed */
141 PT_JOB_HELD, /** held for printing */
142 PT_JOB_PROCESSING, /** currently printing */
143 PT_JOB_STOPPED, /** stopped */
144 PT_JOB_CANCELED, /** canceled */
145 PT_JOB_ABORTED, /** aborted due to error */
146 PT_JOB_COMPLETED /** completed successfully */
150 Eina_List *printerlist; /** printer list*/
151 void *userdata; /** user data*/
152 } pt_response_data_t;
154 typedef enum _pt_event_e {
156 PT_EVENT_JOB_PENDING,
157 PT_EVENT_JOB_STARTED,
159 PT_EVENT_JOB_PROCESSING,
160 PT_EVENT_JOB_PROGRESS,
161 PT_EVENT_JOB_STOPPED,
162 PT_EVENT_JOB_CANCELED,
163 PT_EVENT_JOB_ABORTED,
164 PT_EVENT_JOB_COMPLETED,
165 PT_EVENT_ALL_THREAD_COMPLETED,
166 PT_EVENT_PRINTER_OFFLINE,
167 PT_EVENT_PRINTER_ONLINE,
168 PT_EVENT_USB_PRINTER_OFFLINE,
169 PT_EVENT_USB_PRINTER_ONLINE,
172 typedef enum _pt_vendor_e {
180 typedef enum _pt_print_option_e {
181 PT_OPTION_ID_PRINTER = 0,
182 PT_OPTION_ID_PAPERSIZE,
185 PT_OPTION_ID_QUALITY,
187 PT_OPTION_ID_GRAYSCALE,
196 } pt_progress_info_t;
198 typedef void (*get_printers_cb)(pt_response_data_t *resp); /** callback function*/
199 typedef void (*pt_event_cb)(pt_event_e event, void *user_data, pt_progress_info_t *progress_info); /** event callback function*/
201 #define NOTI_CONVERT_PDF_COMPLETE "mobileprint_convert_pdf_complete"
202 #define NOTI_CONVERT_PDF_ERROR "mobileprint_convert_pdf_error"
203 #define NOTI_USB_PRINTER_CHECK_ONLINE "mobileprint_usb_printer_online"
204 #define NOTI_USB_PRINTER_CHECK_OFFLINE "mobileprint_usb_printer_offline"
207 char keyword[PT_MAX_LENGTH];
208 char value[PT_QUALITY_ANY][PT_MAX_LENGTH];
209 } pt_quality_value_t;
212 char keyword[PT_MAX_LENGTH];
213 char value[PT_PAPER_ANY][PT_MAX_LENGTH];
217 char keyword[PT_MAX_LENGTH];
218 char value[PT_GRAYSCALE_ANY][PT_MAX_LENGTH];
222 char name[PT_MAX_LENGTH]; /** the description of the printer */
223 char address[PT_MAX_LENGTH]; /** ip address */
224 char mdl[PT_MAX_LENGTH]; /* mdl name */
225 char mfg[PT_MAX_LENGTH]; /* mfg name */
226 char ppd[PT_MAX_LENGTH]; /** ppd file name (with full path) */
227 gboolean is_ppd_exist;
228 int authrequired; /** reserved, the type of authentication required for printing:
230 * 1- username,password,
231 * 2- domain,username,password,
234 int support_color; /** reserved
235 * 0- the printer unsupports color mode,
236 * 1- the printer supports color mode.
238 int support_duplex; /** reserved
239 * 0- the printer unsupports duplex mode,
240 * 1- the printer supports duplex mode.
242 pt_printer_state_e status; /** printer status */
243 int actived; /** actived printer */
245 int copies; /** print copy number */
246 int size; /** paper size */
247 pt_orientation_e landscape; /** orientation */
248 pt_scaling_e scaling; /** scaling mode */
249 pt_image_size_option_e imagesize; /** image size */
250 pt_range_e range; /** printing range */
251 // pt_grayscale_t grayscale; /** colour mode */
252 // pt_quality_t quality; /** quality */
253 // pt_paper_t paper; /** paper type */
257 char name[PT_MAX_LENGTH];
263 pt_image_size_option_e imagesize;
264 double resolution_width;
265 double resolution_height;
267 int unit; // 1:cm 2:inch
271 * This API let the app initialize the environment(eg.ip address) by type
272 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
273 * @param[in] type connection type enumerated in pt_connection_type
274 * @param[in] type event callback function
276 API int pt_init(pt_event_cb evt_cb, void *user_data);
279 * This API let the app finalize the environment
280 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
282 API int pt_deinit(void);
285 * This API let the app get the printer list
286 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
287 * @param[in] callback the pointer to the function which will be excuted after search
288 * @param[in] userdata the pointer to the user data
290 static void test_cb(pt_response_data_t *resp)
295 if (NULL == resp->printerlist)
298 Eina_List* cursor = NULL;
299 pt_printer_mgr_t* printer = NULL;
301 EINA_LIST_FOREACH(resp->printerlist,cursor,printer)
312 pt_get_printers(test_cb, userdata);
317 API int pt_get_printers(get_printers_cb callback, void *userdata);
320 * This API let the app cancel getting the printer list
321 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
323 API int pt_cancel_get_printers();
326 * This API let the app get the current default printer
327 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
328 * @param[out] printer the pointer to the printer object
333 pt_printer_mgr_t *pt;
334 int ret = pt_get_default_printer(&pt);
335 if(ret != PT_ERR_NONE)
341 API int pt_get_default_printer(pt_printer_mgr_t **printer);
344 * This API let the app set a printer as the default printer
345 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
346 * @param[in] printer the pointer to the printer object
348 API int pt_set_default_printer(pt_printer_mgr_t *printer);
351 * This API let the app get the current active printer
352 * allocates memory for printer info structure! Please free after use!
353 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
354 * @param[out] printer the pointer to the printer object
356 int pt_get_active_printer(pt_printer_mgr_t **printer);
359 * This API let the app select a specify printer as active printer
360 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
361 * @param[in] printer the pointer to the printer object
363 API int pt_set_active_printer(pt_printer_mgr_t *printer);
366 * This API let the app set page ranges option for active printer, if not find active printer, will use default printer
367 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
368 * @param[in] ranges page range string
370 API int pt_set_print_option_page_range(const char *ranges);
373 * This API let the app set copies option for active printer, if not find active printer, will use default printer
374 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
375 * @param[in] copies the copy number
377 API int pt_set_print_option_copies(int copies);
380 * This API let the app set paper option for active printer, if not find active printer, will use default printer
381 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
382 * @param[in] papersize the paper size
384 API int pt_set_print_option_papersize(void);
387 * This API let the app set orientation option for active printer, if not find active printer, will use default printer
388 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
389 * @param[in] orientation the orientation value(0:portrait, 1:landscape)
391 API int pt_set_print_option_orientation(pt_orientation_e orientation);
394 * This API let the app set image fit for the page size, if not find active printer, will use default printer
395 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
397 API int pt_set_print_option_imagesize(pt_imagesize_t *crop_image_info, const char *filepath, int res_x, int res_y);
400 * This API let the app set image fit for the page size, if not find active printer, will use default printer
401 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
403 API int pt_set_print_option_scaleimage(pt_scaling_e scaling);
406 * This API let the app set the color mode (if supported by printer)
407 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
409 API int pt_set_print_option_color(void);
412 * This API let the app set the print quality (if supported by printer)
413 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
415 API int pt_set_print_option_quality(void);
418 * This API let the app set the paper type (if supported by printer)
419 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
421 API int pt_set_print_option_paper_type(void);
424 * This API let the app start the print job on the active printer, if not find active printer, will use default printer
425 * now only support image and txt file,
426 * will support pdf,office,eml,html in the future
427 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
428 * @param[in] files is the print files path address
429 * @param[in] num is the print files number
430 * @param[out] jobid the job id
432 API int pt_start_print(const char **files, int num);
435 * This API let the app cancel the print job by jobid
436 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
437 * @param[in] jobid the job id
439 API int pt_cancel_print(int jobid);
442 * This API let the app get the connect status
443 * @return If success, return PT_ERR_CONNECTION_USB_ACCESS or PT_ERR_CONNECTION_WIFI_ACCESS,
444 * else return the other error code as defined in pt_err_t
446 API int pt_get_connection_status(int *connection_type);
449 * This API let the app get the job status
450 * @return return job status
453 API pt_job_state_e pt_get_current_job_status(int jobid);
456 * This API check the printer status
457 * @return If success, return PT_ERR_NONE, else return the other error code as defined in pt_err_t
459 API pt_printer_state_e pt_check_printer_status(pt_printer_mgr_t *printer);
462 * This API returns the human-readable paper size. "papersize_num" is it's position in the PPD file.
463 * @return The pointer to the string or NULL if problem
465 API char *pt_get_print_option_papersize(int papersize_num);
468 * This API returns the printer instruction for setting paper size. "papersize_num" is it's position in the PPD file.
469 * @return The pointer to the string or NULL if problem
471 API char *pt_get_print_option_papersize_cmd(int papersize_num);
474 * This API returns the number of paper sizes in the PPD.
476 API int pt_get_print_option_papersize_num(void);
479 * This API returns the position of the default paper size in the PPD.
481 //API int pt_get_print_option_default_papersize(void);
484 * This API selects(marks) the choice number ch of the option op.
487 API int pt_set_choice(int op, int ch);
490 * This API returns the number of the selected choice of the option op.
492 API int pt_get_selected(int op);
495 * This API checks if the choice ch of the option op can be selected (is enabled).
497 API int pt_is_enabled(int op, int ch);
500 * This API returns the selected page size in points.
502 API int pt_get_selected_paper_size_pts(pt_pagesize_t *s);
504 #endif /* __PRINT_SERVICE_API_H__ */