summaryrefslogtreecommitdiff
path: root/src/scanner.h
blob: 5acdc84da8d9f764414595579850ebb096648c8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
 * Copyright (C) 2009 Canonical Ltd.
 * Author: Robert Ancell <robert.ancell@canonical.com>
 * 
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
 * license.
 */

#ifndef _SCANNER_H_
#define _SCANNER_H_

#include <glib-object.h>

G_BEGIN_DECLS

#define SCANNER_TYPE  (scanner_get_type ())
#define SCANNER(obj)  (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCANNER_TYPE, Scanner))


typedef struct
{
    gchar *name, *label;
} ScanDevice;

typedef struct
{
    /* Width, height in pixels */
    gint width, height;

    /* Bit depth */
    gint depth;

    /* Resolution */
    gdouble dpi;

    /* The device this page came from */
    gchar *device;
} ScanPageInfo;

typedef struct
{
    /* Line number */
    gint number;
  
    /* Number of lines in this packet */
    gint n_lines;

    /* Width in pixels and format */
    gint width, depth;
    enum
    {
        LINE_GRAY,
        LINE_RGB,
        LINE_RED,
        LINE_GREEN,
        LINE_BLUE
    } format;
    
    /* Raw line data */
    guchar *data;
    gsize data_length;
} ScanLine;

typedef enum
{
    SCAN_MODE_DEFAULT,    
    SCAN_MODE_COLOR,
    SCAN_MODE_GRAY,
    SCAN_MODE_LINEART
} ScanMode;

typedef enum
{
    SCAN_SINGLE,
    SCAN_ADF_FRONT,
    SCAN_ADF_BACK,
    SCAN_ADF_BOTH
} ScanType;

typedef struct
{
    gint dpi;
    ScanMode scan_mode;
    gint depth;
    ScanType type;
    gint paper_width, paper_height;
} ScanOptions;

typedef struct ScannerPrivate ScannerPrivate;

typedef struct
{
    GObject         parent_instance;
    ScannerPrivate *priv;
} Scanner;

typedef struct
{
    GObjectClass parent_class;

    void (*update_devices) (Scanner *scanner, GList *devices);
    void (*authorize) (Scanner *scanner, const gchar *resource);
    void (*expect_page) (Scanner *scanner);
    void (*got_page_info) (Scanner *scanner, ScanPageInfo *info);
    void (*got_line) (Scanner *scanner, ScanLine *line);
    void (*scan_failed) (Scanner *scanner, GError *error);
    void (*page_done) (Scanner *scanner);
    void (*document_done) (Scanner *scanner);
    void (*scanning_changed) (Scanner *scanner);
} ScannerClass;


GType scanner_get_type (void);

Scanner *scanner_new (void);

void scanner_start (Scanner *scanner);

void scanner_authorize (Scanner *scanner, const gchar *username, const gchar *password);

void scanner_redetect (Scanner *scanner);

gboolean scanner_is_scanning (Scanner *scanner);

void scanner_scan (Scanner *scanner, const char *device, ScanOptions *options);

void scanner_cancel (Scanner *scanner);

void scanner_free (Scanner *scanner);

#endif /* _SCANNER_H_ */