Merging NList MCC 0.119 into the main branch.
[AROS.git] / workbench / classes / zune / nlist / nlist_mcc / library.c
blobd963ac5eccec5356952e854bc837cdc3ca0b7f43
1 /***************************************************************************
3 NList.mcc - New List MUI Custom Class
4 Registered MUI class, Serial Number: 1d51 0x9d510030 to 0x9d5100A0
5 0x9d5100C0 to 0x9d5100FF
7 Copyright (C) 1996-2001 by Gilles Masson
8 Copyright (C) 2001-2014 NList Open Source Team
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 NList classes Support Site: http://www.sf.net/projects/nlist-classes
22 $Id$
24 ***************************************************************************/
26 /******************************************************************************/
27 /* */
28 /* includes */
29 /* */
30 /******************************************************************************/
32 #include <proto/exec.h>
33 #include <proto/intuition.h>
35 /******************************************************************************/
36 /* */
37 /* MCC/MCP name and version */
38 /* */
39 /* ATTENTION: The FIRST LETTER of NAME MUST be UPPERCASE */
40 /* */
41 /******************************************************************************/
43 #include "private.h"
44 #include "version.h"
45 #include "NList_grp.h"
47 /******************************************************************************/
48 /* include the minimal startup code to be able to start the class from a */
49 /* shell without crashing the system */
50 /******************************************************************************/
51 #include "shellstart.c"
53 #define VERSION LIB_VERSION
54 #define REVISION LIB_REVISION
56 #define CLASS MUIC_NList
57 #define SUPERCLASS MUIC_Group
59 #define INSTDATA NLData
61 #define USERLIBID CLASS " " LIB_REV_STRING " [" SYSTEMSHORT "/" CPU "] (" LIB_DATE ") " LIB_COPYRIGHT
62 #define MASTERVERSION 19
64 #define CLASSINIT
65 #define CLASSEXPUNGE
67 #define USEDCLASSESP used_mcps
68 static const char *used_mcps[] = { "NListviews.mcp", NULL };
70 #define MIN_STACKSIZE 16384
72 #if defined(__MORPHOS__)
73 struct Library *LayersBase = NULL;
74 struct Library *DiskfontBase = NULL;
75 struct Library *ConsoleDevice = NULL;
76 #else
77 struct Library *LayersBase = NULL;
78 struct Library *DiskfontBase = NULL;
79 struct Device *ConsoleDevice = NULL;
80 #endif
82 #if defined(__amigaos4__)
83 struct LayersIFace *ILayers = NULL;
84 struct DiskfontIFace *IDiskfont = NULL;
85 struct ConsoleIFace *IConsole = NULL;
86 #endif
88 static struct IOStdReq ioreq;
90 #if defined(DEBUG)
91 #include "timeval.h"
92 static struct TimeRequest timereq;
93 #if defined(__MORPHOS__)
94 struct Library *TimerBase = NULL;
95 #else
96 struct Device *TimerBase = NULL;
97 #endif
98 #if defined(__amigaos4__)
99 struct TimerIFace *ITimer = NULL;
100 #endif
101 #endif // DEBUG
103 /******************************************************************************/
104 /* define the functions used by the startup code ahead of including mccinit.c */
105 /******************************************************************************/
106 static BOOL ClassInit(UNUSED struct Library *base);
107 static VOID ClassExpunge(UNUSED struct Library *base);
109 /******************************************************************************/
110 /* include the lib startup code for the mcc/mcp (and muimaster inlines) */
111 /******************************************************************************/
112 #include "mccinit.c"
114 /******************************************************************************/
115 /* define all implementations of our user functions */
116 /******************************************************************************/
117 static BOOL ClassInit(UNUSED struct Library *base)
119 if((LayersBase = OpenLibrary("layers.library", 39L)) &&
120 GETINTERFACE(ILayers, struct LayersIFace *, LayersBase))
122 if((DiskfontBase = OpenLibrary("diskfont.library", 39L)) &&
123 GETINTERFACE(IDiskfont, struct DiskfontIFace *, DiskfontBase))
125 memset(&ioreq, 0, sizeof(ioreq));
126 ioreq.io_Message.mn_Length = sizeof(ioreq);
127 if(OpenDevice("console.device", -1L, (struct IORequest *)&ioreq, 0L) == 0)
129 ConsoleDevice = (APTR)ioreq.io_Device;
130 if(GETINTERFACE(IConsole, struct ConsoleIFace *, ConsoleDevice))
132 #if defined(DEBUG)
133 memset(&timereq, 0, sizeof(timereq));
134 timereq.Request.io_Message.mn_Length = sizeof(timereq);
135 if(OpenDevice("timer.device", 0, (struct IORequest *)&timereq, 0L) == 0)
137 TimerBase = timereq.Request.io_Device;
138 if(GETINTERFACE(ITimer, struct TimerIFace *, TimerBase))
140 #endif // DEBUG
141 if(NGR_Create())
143 if(StartClipboardServer() == TRUE)
145 return(TRUE);
149 #if defined(DEBUG)
150 DROPINTERFACE(ITimer);
153 #endif // DEBUG
155 DROPINTERFACE(IConsole);
158 CloseDevice((struct IORequest *)&ioreq);
159 ConsoleDevice = NULL;
162 DROPINTERFACE(IDiskfont);
163 CloseLibrary(DiskfontBase);
164 DiskfontBase = NULL;
167 DROPINTERFACE(ILayers);
168 CloseLibrary(LayersBase);
169 LayersBase = NULL;
172 return(FALSE);
176 static VOID ClassExpunge(UNUSED struct Library *base)
178 ShutdownClipboardServer();
180 NGR_Delete();
182 #if defined(DEBUG)
183 if(TimerBase)
185 DROPINTERFACE(ITimer);
186 CloseDevice((struct IORequest *)&timereq);
187 TimerBase = NULL;
189 #endif // DEBUG
191 if(ConsoleDevice)
193 DROPINTERFACE(IConsole);
194 CloseDevice((struct IORequest *)&ioreq);
195 ConsoleDevice = NULL;
198 if(DiskfontBase)
200 DROPINTERFACE(IDiskfont);
201 CloseLibrary(DiskfontBase);
202 DiskfontBase = NULL;
205 if(LayersBase)
207 DROPINTERFACE(ILayers);
208 CloseLibrary(LayersBase);
209 LayersBase = NULL;