1fd17f6d4SPhilippe Houdoin /*****************************************************************************/
2fd17f6d4SPhilippe Houdoin // HP JetDirect (TCP/IP only) transport add-on,
3fd17f6d4SPhilippe Houdoin //
4fd17f6d4SPhilippe Houdoin // Author
5fd17f6d4SPhilippe Houdoin // Philippe Houdoin
6fd17f6d4SPhilippe Houdoin //
7fd17f6d4SPhilippe Houdoin // This application and all source files used in its construction, except
8fd17f6d4SPhilippe Houdoin // where noted, are licensed under the MIT License, and have been written
9fd17f6d4SPhilippe Houdoin // and are:
10fd17f6d4SPhilippe Houdoin //
11*2ca13760SColdfirex // Copyright (c) 2001-2003 Haiku Project
12fd17f6d4SPhilippe Houdoin //
13fd17f6d4SPhilippe Houdoin // Permission is hereby granted, free of charge, to any person obtaining a
14fd17f6d4SPhilippe Houdoin // copy of this software and associated documentation files (the "Software"),
15fd17f6d4SPhilippe Houdoin // to deal in the Software without restriction, including without limitation
16fd17f6d4SPhilippe Houdoin // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17fd17f6d4SPhilippe Houdoin // and/or sell copies of the Software, and to permit persons to whom the
18fd17f6d4SPhilippe Houdoin // Software is furnished to do so, subject to the following conditions:
19fd17f6d4SPhilippe Houdoin //
20fd17f6d4SPhilippe Houdoin // The above copyright notice and this permission notice shall be included
21fd17f6d4SPhilippe Houdoin // in all copies or substantial portions of the Software.
22fd17f6d4SPhilippe Houdoin //
23fd17f6d4SPhilippe Houdoin // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24fd17f6d4SPhilippe Houdoin // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25fd17f6d4SPhilippe Houdoin // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26fd17f6d4SPhilippe Houdoin // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27fd17f6d4SPhilippe Houdoin // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28fd17f6d4SPhilippe Houdoin // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29fd17f6d4SPhilippe Houdoin // DEALINGS IN THE SOFTWARE.
30fd17f6d4SPhilippe Houdoin /*****************************************************************************/
31fd17f6d4SPhilippe Houdoin
32fd17f6d4SPhilippe Houdoin
33fd17f6d4SPhilippe Houdoin #include <Message.h>
34fd17f6d4SPhilippe Houdoin #include <Directory.h>
35fd17f6d4SPhilippe Houdoin #include <SupportKit.h>
36fd17f6d4SPhilippe Houdoin
37fd17f6d4SPhilippe Houdoin #include "HPJetDirectTransport.h"
38fd17f6d4SPhilippe Houdoin
39fd17f6d4SPhilippe Houdoin static BDataIO * g_transport = NULL;
40fd17f6d4SPhilippe Houdoin
41fd17f6d4SPhilippe Houdoin // Implementation of transport add-on interface
init_transport(BMessage * msg)42fd17f6d4SPhilippe Houdoin extern "C" _EXPORT BDataIO * init_transport(BMessage *msg)
43fd17f6d4SPhilippe Houdoin {
44fd17f6d4SPhilippe Houdoin if (msg == NULL)
45fd17f6d4SPhilippe Houdoin return NULL;
46fd17f6d4SPhilippe Houdoin
47fd17f6d4SPhilippe Houdoin if (g_transport)
48fd17f6d4SPhilippe Houdoin return NULL;
49fd17f6d4SPhilippe Houdoin
50fd17f6d4SPhilippe Houdoin const char* printer_name = msg->FindString("printer_file");
51fd17f6d4SPhilippe Houdoin
52fd17f6d4SPhilippe Houdoin if (printer_name && *printer_name != '\0') {
53fd17f6d4SPhilippe Houdoin BDirectory printer(printer_name);
54fd17f6d4SPhilippe Houdoin
55fd17f6d4SPhilippe Houdoin if (printer.InitCheck() == B_OK) {
56fd17f6d4SPhilippe Houdoin HPJetDirectPort * transport = new HPJetDirectPort(&printer, msg);
57fd17f6d4SPhilippe Houdoin
58179268dcSPhilippe Houdoin if (transport->InitCheck() == B_OK) {
59fd17f6d4SPhilippe Houdoin g_transport = transport;
60bc333ea2SPhilippe Houdoin if (msg)
61986f1ba6SPhilippe Houdoin msg->what = 'okok';
62fd17f6d4SPhilippe Houdoin return g_transport;
63fd17f6d4SPhilippe Houdoin };
64fd17f6d4SPhilippe Houdoin
65fd17f6d4SPhilippe Houdoin delete transport;
66fd17f6d4SPhilippe Houdoin };
67fd17f6d4SPhilippe Houdoin };
68fd17f6d4SPhilippe Houdoin return NULL;
69fd17f6d4SPhilippe Houdoin }
70fd17f6d4SPhilippe Houdoin
exit_transport()71fd17f6d4SPhilippe Houdoin extern "C" _EXPORT void exit_transport()
72fd17f6d4SPhilippe Houdoin {
73fd17f6d4SPhilippe Houdoin if (g_transport)
74fd17f6d4SPhilippe Houdoin delete g_transport;
75fd17f6d4SPhilippe Houdoin g_transport = NULL;
76fd17f6d4SPhilippe Houdoin }
77