564bb95551dfb13bd3c072fb67d367c0f52f982c
[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.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
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 MAX_URI_SIZE (512)
29
30 typedef struct {
31         char product_ui_name[PT_MAX_LENGTH];            /* product display name in UI */
32         char device_info[PT_MAX_LENGTH];        /* printer info used as key of hashtable*/
33         char device_uri[PT_MAX_LENGTH];                 /* url */
34         char model_name[PT_MAX_LENGTH];                 /* mdl name */
35         char manufacturer[PT_MAX_LENGTH];                       /* mfg name     */
36         char ppd_file_path[PT_MAX_LENGTH];                    /** ppd file name (with full path) */
37 //      int     color;                                                  /* 0-F, 1-T, 2-U */
38 //      int     duplex;                                                 /* 0-F, 1-T, 2-U */
39 } pt_printer_info_t;
40
41 /*
42 typedef struct {
43         pt_printer_info_t *printer_info;
44         pt_printer_status_t *printer_status;
45 } pt_printer_t;
46
47 typedef struct {
48 } pt_printer_status_t;
49
50 typedef struct {
51         pts_printing_data_t *data;
52         pt_job_info_t   *info;
53         pt_notification_t *notification_plugin;
54         pt_print_option_t *option;
55 } pt_job_t;
56
57 typedef struct {
58 } pt_print_option_t;
59
60 typedef struct {
61 } pt_notification_t;
62 */
63
64
65 typedef struct {
66         int  id;                                                                        /** job id */
67         int  priority;                                                          /** priority (1-100) */
68         int  subscription_id;
69         int  sequence_num;
70         int  progress;
71         pt_job_state_e status;                                          /** job status */
72         char title[PT_MAX_LENGTH];                                      /** title/job name */
73         char user[PT_MAX_LENGTH];                                       /** reserved, username who submitted the job */
74         pt_printer_mgr_t *printer;                                      /** the pointer to the associated printer object */
75 } pt_job_info_t;
76
77 typedef struct {
78         int is_searching;
79         Eina_List *pt_local_list;
80         pt_response_data_t response_data;
81         get_printers_cb user_cb;
82 } pt_search_data_t;
83
84 typedef enum {
85         PT_SEARCH_IDLE,
86         PT_SEARCH_IN_PROGRESS,
87         PT_SEARCH_CANCEL,
88         PT_SEARCH_END,
89 } pt_searching_state_e;
90
91 typedef enum {
92         PT_PRINT_IDLE,
93         PT_PRINT_HELD,
94         PT_PRINT_PENDING,
95         PT_PRINT_IN_PROGRESS,
96         PT_PRINT_ABORT,
97         PT_PRINT_CANCEL,
98         PT_PRINT_STOP,
99         PT_PRINT_END,
100 } pt_printing_state_e;
101
102 typedef struct {
103         const char                      **files;
104         int                                     num_files;
105         Ecore_Thread            *printing_thd_hdl;
106         pt_job_info_t           *job;                                   /** job info */
107         pt_printing_state_e     printing_state;
108         Ecore_Timer                     *job_noti_timer;
109         int                                     page_printed;
110 } pt_printing_job_t;
111
112 typedef struct {
113         pt_connection_type_e connect_type;                      /** assigned connection type */
114         pt_printer_mgr_t        *active_printer;                /** active printer info */
115         pt_search_data_t                *search;
116
117         cups_option_t           *job_options;
118         int num_options;                                                        /** print job option */
119
120         int                                     ueventsocket;                   /* hotplug event socket */
121         int                                     avahi_pid;                              /* avahi pid */
122         int                                     cups_pid;                               /* cups pid */
123
124         Ecore_Timer                     *cups_checking_timer;
125         Ecore_Thread            *searching_thd_hdl;
126         pt_searching_state_e    searching_state;
127         Eina_List                       *printing_thd_list;
128
129         pt_event_cb                     evt_cb;
130         void                            *user_data;
131 } pt_info_t;
132
133 extern pt_info_t *g_pt_info;                                    /** print info maintained globally */
134 extern ppd_file_t *ppd;
135
136 #endif /* __PRINT_SERVICE_H__ */