Tizen 2.1 base
[apps/core/preloaded/print-service.git] / include / pt_common.h
1 /*
2 *       Printservice
3 *
4 * Copyright 2012  Samsung Electronics Co., Ltd
5
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
9
10 * http://floralicense.org/license/
11
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.
17 *
18 */
19
20 #ifndef __PRINT_SERVICE_H__
21 #define __PRINT_SERVICE_H__
22
23 #include <cups/cups.h>
24 #include <cups/ppd.h>
25 #include "pt_api.h"
26 #include "pt_utils.h"
27
28 #define CUPS_161_UPGRADE
29
30 #define MAX_URI_SIZE (512)
31
32 typedef struct {
33         char product_ui_name[PT_MAX_LENGTH];            /* product display name in UI */
34         char device_info[PT_MAX_LENGTH];        /* printer info used as key of hashtable*/
35         char device_uri[PT_MAX_LENGTH];                 /* url */
36         char model_name[PT_MAX_LENGTH];                 /* mdl name */
37         char manufacturer[PT_MAX_LENGTH];                       /* mfg name     */
38         char ppd_file_path[PT_MAX_LENGTH];                    /** ppd file name (with full path) */
39 //      int     color;                                                  /* 0-F, 1-T, 2-U */
40 //      int     duplex;                                                 /* 0-F, 1-T, 2-U */
41 } pt_printer_info_t;
42
43 /*
44 typedef struct {
45         pt_printer_info_t *printer_info;
46         pt_printer_status_t *printer_status;
47 } pt_printer_t;
48
49 typedef struct {
50 } pt_printer_status_t;
51
52 typedef struct {
53         pts_printing_data_t *data;
54         pt_job_info_t   *info;
55         pt_notification_t *notification_plugin;
56         pt_print_option_t *option;
57 } pt_job_t;
58
59 typedef struct {
60 } pt_print_option_t;
61
62 typedef struct {
63 } pt_notification_t;
64 */
65
66 typedef struct {
67         int  copies;                                                    /** the number of copies */
68         int  orientation;                                               /** 0- portrait mode,
69                                                                                           * 1- landscape mode
70                                                                                           */
71         pt_paper_size_e   papersize;                    /** reserved, paper size */
72
73 #if 0 // copied from pt_printer_mgr_t
74         int                             copies;                                 /** print copy number */
75         int                             size;                                   /** paper size */
76         pt_orientation_e        landscape;                              /** orientation */
77         pt_scaling_e            scaling;                                        /** scaling mode */
78         pt_image_size_option_e  imagesize;                              /** image size */
79         pt_range_e              range;                                  /** printing range */
80 //      pt_grayscale_t grayscale;                                       /** colour mode */
81 //      pt_quality_t quality;                                           /** quality */
82 //      pt_paper_t paper;                                                       /** paper type */
83 #endif
84 } pt_print_option_t;
85
86 typedef struct {
87         int  id;                                                                        /** job id */
88         int  priority;                                                          /** priority (1-100) */
89         int  subscription_id;
90         int  sequence_num;
91         int  progress;
92         pt_job_state_e status;                                          /** job status */
93         char title[PT_MAX_LENGTH];                                      /** title/job name */
94         char user[PT_MAX_LENGTH];                                       /** reserved, username who submitted the job */
95         pt_printer_mgr_t *printer;                                      /** the pointer to the associated printer object */
96 } pt_job_info_t;
97
98 typedef struct {
99         int is_searching;
100         Eina_List *pt_local_list;
101         pt_response_data_t response_data;
102         get_printers_cb user_cb;
103 } pt_search_data_t;
104
105 typedef enum {
106         PT_SEARCH_IDLE,
107         PT_SEARCH_IN_PROGRESS,
108         PT_SEARCH_CANCEL,
109         PT_SEARCH_END,
110 } pt_searching_state_e;
111
112 typedef enum {
113         PT_PRINT_IDLE,
114         PT_PRINT_HELD,
115         PT_PRINT_PENDING,
116         PT_PRINT_IN_PROGRESS,
117         PT_PRINT_ABORT,
118         PT_PRINT_CANCEL,
119         PT_PRINT_STOP,
120         PT_PRINT_END,
121 } pt_printing_state_e;
122
123 typedef struct {
124         const char                      **files;
125         int                                     num_files;
126         Ecore_Thread            *printing_thd_hdl;
127         pt_job_info_t           *job;                                   /** job info */
128         pt_printing_state_e     printing_state;
129         Ecore_Timer                     *job_noti_timer;
130         int                                     page_printed;
131 } pt_printing_job_t;
132
133 typedef struct {
134         pt_connection_type_e connect_type;                      /** assigned connection type */
135         pt_printer_mgr_t        *active_printer;                /** active printer info */
136         pt_print_option_t       *option;                                /** print option */
137         pt_search_data_t                *search;
138
139         cups_option_t           *job_options;
140         int num_options;                                                        /** print job option */
141
142         int                                     ueventsocket;                   /* hotplug event socket */
143         int                                     avahi_pid;                              /* avahi pid */
144         int                                     cups_pid;                               /* cups pid */
145
146         Ecore_Timer                     *cups_checking_timer;
147         Ecore_Thread            *searching_thd_hdl;
148         pt_searching_state_e    searching_state;
149         Eina_List                       *printing_thd_list;
150
151         pt_event_cb                     evt_cb;
152         void                            *user_data;
153 } pt_info_t;
154
155 extern pt_info_t *g_pt_info;                                    /** print info maintained globally */
156
157 /* prototypes */
158 void pt_parse_options(ppd_file_t *ppd);
159 ppd_choice_t *pt_selected_choice(int op);
160 ppd_size_t *pt_utils_paper_size_pts(const char *name);
161
162 #endif /* __PRINT_SERVICE_H__ */