~ubuntu-branches/ubuntu/vivid/lazarus/vivid

« back to all changes in this revision

Viewing changes to components/sqldb/registersqldb.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Paul Gevers
  • Date: 2014-02-22 10:25:57 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20140222102557-ors9d31r84nz31jq
Tags: 1.2~rc2+dfsg-1
[ Abou Al Montacir ]
* New upstream pre-release.
  + Moved ideintf to components directory.
  + Added new package cairocanvas.
* Remove usage of depreciated parameters form of find. (Closes: Bug#724776)
* Bumped standard version to 3.9.5.
* Clean the way handling make files generation and removal.

[ Paul Gevers ]
* Remove nearly obsolete bzip compression for binary packages
  (See https://lists.debian.org/debian-devel/2014/01/msg00542.html)
* Update d/copyright for newly added dir in examples and components
* Update Vcs-* fields with new packaging location
* Update d/watch file to properly (Debian way) change upstreams versions
* Prevent 46MB of package size by sym linking duplicate files
* Patches
  - refresh to remove fuzz
  - add more Lintian found spelling errors
  - new patch to add shbang to two scripts in lazarus-src
* Drop lcl-# from Provides list of lcl-units-#
* Make lazarus-ide-qt4-# an arch all until it really contains stuff
* Make all metapackages arch all as the usecase for arch any doesn't
  seem to warrant the addition archive hit
* Fix permissions of non-scripts in lazarus-src-#

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{  $Id: registersqldb.pas 37536 2012-06-07 08:27:21Z zeljko $  }
 
1
{  $Id: registersqldb.pas 43618 2013-12-30 22:46:53Z maxim $  }
2
2
{
3
3
 *****************************************************************************
4
 
 *                                                                           *
5
 
 *  See the file COPYING.modifiedLGPL.txt, included in this distribution,        *
6
 
 *  for details about the copyright.                                         *
7
 
 *                                                                           *
8
 
 *  This program is distributed in the hope that it will be useful,          *
9
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
10
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
11
 
 *                                                                           *
 
4
  See the file COPYING.modifiedLGPL.txt, included in this distribution,
 
5
  for details about the license.
12
6
 *****************************************************************************
13
7
 
14
8
  Author: Joost van der Sluis
21
15
{$IFNDEF win64}
22
16
{$DEFINE HASMYSQL4CONNECTION}
23
17
{$DEFINE HASORACLECONNECTION}
24
 
{$DEFINE HASPQCONNECTION}
25
18
{$DEFINE HASSQLITE3CONNECTION}
26
19
{$ENDIF}
27
20
 
28
 
{$IF FPC_FULLVERSION> 20402}
29
 
{$DEFINE HASMYSQL51CONNECTION}
30
 
{$DEFINE HASSQLPARSER}
31
 
{$ENDIF}
 
21
{$IF FPC_FULLVERSION>=20602}
 
22
{$DEFINE HASSQLITE3CONNECTION} // Include for win64, if fpc > 2.6.2
 
23
{$ENDIF}
 
24
 
 
25
{$IF FPC_FULLVERSION>= 20601}
 
26
{$DEFINE HASPQCONNECTION}
 
27
{$ELSE}
 
28
{$IFNDEF win64}
 
29
{$DEFINE HASPQCONNECTION}
 
30
{$ENDIF}
 
31
{$ENDIF}
 
32
 
32
33
 
33
34
{$IF FPC_FULLVERSION>= 20601}
34
35
{$DEFINE HASMYSQL55CONNECTION}
35
 
{$ENDIF}
36
 
 
37
 
{$IF FPC_FULLVERSION>= 20601}
38
36
{$IF DEFINED(BEOS) OR DEFINED(HAIKU) OR DEFINED(LINUX) OR DEFINED(FREEBSD) OR DEFINED (NETBSD) OR DEFINED(OPENBSD) OR DEFINED(WIN32) OR DEFINED(WIN64)}
39
 
// MS SQL Server and Sybase ASE connectors were introduced in the FPC 2.7 development branch, and
40
 
// backported to 2.6.1
41
 
// Operating systems should match FPC packages\fcl-db\fpmake.pp
 
37
// MS SQL Server and Sybase ASE connectors were introduced in the FPC 2.7 development branch,
 
38
//  and backported to 2.6.1. Operating systems should match FPC packages\fcl-db\fpmake.pp
42
39
{$DEFINE HASMSSQLCONNECTION}
43
40
{$DEFINE HASSYBASECONNECTION}
44
41
{$ENDIF}
45
42
{$ENDIF}
46
43
 
 
44
{$IF FPC_FULLVERSION >= 20602} 
 
45
// These were backported to FPC 2.6.2
 
46
 {$DEFINE HASFBADMIN}
 
47
 {$DEFINE HASPQEVENT}
 
48
 {$DEFINE HASFBEVENT}
 
49
 {$DEFINE HASLIBLOADER}
 
50
{$ENDIF}
 
51
 
 
52
{$IF FPC_FULLVERSION>= 20603}
 
53
{$DEFINE HASMYSQL56CONNECTION}
 
54
{$ENDIF}
 
55
 
 
56
{$IFNDEF Solaris}
 
57
{$DEFINE HASIBCONNECTION}
 
58
{$ENDIF}
 
59
 
47
60
interface
48
61
 
49
62
uses
50
63
  Classes, SysUtils, LResources, db, sqldb,
51
 
  ibconnection,
52
 
{$IFDEF HASMSSQLCONNECTION}  
53
 
  // mssqlconn provide both MS SQL Server and Sybase ASE connectors.
54
 
  mssqlconn,
55
 
{$ENDIF}
 
64
  {$IFDEF HASIBCONNECTION}
 
65
    ibconnection,
 
66
  {$ENDIF}
 
67
  {$IFDEF HASMSSQLCONNECTION}
 
68
    // mssqlconn provide both MS SQL Server and Sybase ASE connectors.
 
69
    mssqlconn,
 
70
  {$ENDIF}
56
71
  odbcconn,
57
 
{$IFDEF HASPQCONNECTION}
58
 
  pqconnection,
59
 
{$ENDIF}
60
 
{$IFDEF HASORACLECONNECTION}
61
 
  oracleconnection,
62
 
{$ENDIF}
 
72
  {$IFDEF HASPQCONNECTION}
 
73
    pqconnection,
 
74
    {$IFDEF HASPQEVENT}
 
75
    pqteventmonitor,
 
76
    {$ENDIF}
 
77
  {$ENDIF}
 
78
  {$IFDEF HASORACLECONNECTION}
 
79
    oracleconnection,
 
80
  {$ENDIF}
63
81
 
64
 
{$IFDEF HASMYSQL4CONNECTION}
65
 
  mysql40conn, mysql41conn,
66
 
{$ENDIF}
67
 
  mysql50conn,
68
 
{$IFDEF HASMYSQL51CONNECTION}
 
82
  {$IFDEF HASMYSQL4CONNECTION}
 
83
    mysql40conn, mysql41conn,
 
84
  {$ENDIF}
 
85
    mysql50conn,
69
86
  mysql51conn,
70
 
{$ENDIF}
71
 
{$IFDEF HASMYSQL55CONNECTION}
72
 
  mysql55conn,
73
 
{$ENDIF}
74
 
{$IFDEF HASSQLITE3CONNECTION}
75
 
  sqlite3conn,
76
 
{$ENDIF}
 
87
  {$IFDEF HASMYSQL55CONNECTION}
 
88
    mysql55conn,
 
89
  {$ENDIF}
 
90
  {$IFDEF HASMYSQL56CONNECTION}
 
91
    mysql56conn,
 
92
  {$ENDIF}
 
93
  {$IFDEF HASSQLITE3CONNECTION}
 
94
    sqlite3conn,
 
95
  {$ENDIF}
 
96
  {$IFDEF HASFBADMIN}
 
97
    fbadmin,
 
98
  {$ENDIF}
 
99
  {$IFDEF HASFBEVENT}
 
100
    fbeventmonitor,
 
101
  {$ENDIF}
77
102
  propedits,
78
103
  sqlstringspropertyeditordlg,
79
104
  controls,
80
105
  forms,
81
 
{$IFDEF HASSQLPARSER}
 
106
  {$IFDEF HASLIBLOADER}
 
107
    sqldblib,
 
108
  {$ENDIF}
82
109
  sqlscript, fpsqltree, fpsqlparser,
83
 
{$ENDIF HASSQLPARSER}
84
110
  LazarusPackageIntf,
85
111
  lazideintf,
86
112
  srceditorintf,
87
113
  ProjectIntf,
88
 
  idemsgintf;
 
114
  idemsgintf,
 
115
  CodeCache,
 
116
  CodeToolManager;
89
117
 
90
118
Type
91
119
  { TSQLStringsPropertyEditor }
117
145
                          {%H-}ResourceName: string): string; override;
118
146
  end;
119
147
 
120
 
 
121
 
{$IFDEF HASSQLPARSER}
 
148
  { TSQLDBConnectorTypePropertyEditor }
 
149
 
 
150
  TSQLDBConnectorTypePropertyEditor = class(TStringPropertyEditor)
 
151
  public
 
152
    function GetAttributes: TPropertyAttributes; override;
 
153
    procedure GetValues(Proc: TGetStrProc); override;
 
154
    procedure SetValue(const NewValue: ansistring); override;
 
155
  end;
 
156
 
 
157
{$IFDEF HASLIBLOADER}
 
158
 
 
159
  { TSQLDBLibraryLoaderLibraryNamePropertyEditor }
 
160
 
 
161
  TSQLDBLibraryLoaderLibraryNamePropertyEditor=class(TFileNamePropertyEditor)
 
162
  public
 
163
    function GetFilter: String; override;
 
164
  end;
 
165
 
 
166
{$ENDIF}
 
167
 
122
168
  TSQLSyntaxChecker = Class(TComponent)
123
169
  private
124
170
    FStatementCount,
133
179
    function CheckSource(Sender: TObject; var Handled: boolean): TModalResult;
134
180
    Property SourceFileName : String Read FSFN;
135
181
 end;
136
 
{$ENDIF HASSQLPARSER}
137
182
 
138
183
procedure Register;
139
184
 
140
185
implementation
141
186
 
 
187
uses dynlibs;
 
188
 
142
189
procedure RegisterUnitSQLdb;
143
190
begin
144
 
  RegisterComponents('SQLdb',[TSQLQuery,
145
 
                              TSQLTransaction,
146
 
                              TSQLScript,
147
 
                              TSQLConnector,
 
191
  RegisterComponents('SQLdb',[
 
192
    TSQLQuery,
 
193
    TSQLTransaction,
 
194
    TSQLScript,
 
195
    TSQLConnector
148
196
{$IFDEF HASMSSQLCONNECTION}                                
149
 
                              TMSSQLConnection,
 
197
    ,TMSSQLConnection
150
198
{$ENDIF}
151
199
{$IFDEF HASSYBASECONNECTION}                                
152
 
                              TSybaseConnection,
 
200
    ,TSybaseConnection
153
201
{$ENDIF}                              
154
202
{$IFDEF HASPQCONNECTION}
155
 
                              TPQConnection,
 
203
    ,TPQConnection
 
204
  {$IFDEF HASPQEVENT}
 
205
      ,TPQTEventMonitor
 
206
  {$ENDIF}
156
207
{$ENDIF}
157
208
{$IFDEF HASORACLECONNECTION}
158
 
                              TOracleConnection,
 
209
    ,TOracleConnection
159
210
{$ENDIF}
160
 
                              TODBCConnection,
 
211
    ,TODBCConnection
161
212
{$IFDEF HASMYSQL4CONNECTION}
162
 
                              TMySQL40Connection,
163
 
                              TMySQL41Connection,
164
 
{$ENDIF}
165
 
                              TMySQL50Connection,
166
 
{$IFDEF HASMYSQL51CONNECTION}
167
 
                              TMySQL51Connection,
168
 
{$ENDIF}
 
213
    ,TMySQL40Connection
 
214
    ,TMySQL41Connection
 
215
{$ENDIF}
 
216
    ,TMySQL50Connection
 
217
    ,TMySQL51Connection
169
218
{$IFDEF HASMYSQL55CONNECTION}
170
 
                              TMySQL55Connection,
 
219
    ,TMySQL55Connection
 
220
{$ENDIF}
 
221
{$IFDEF HASMYSQL56CONNECTION}
 
222
    ,TMySQL56Connection
171
223
{$ENDIF}
172
224
{$IFDEF HASSQLITE3CONNECTION}
173
 
                              TSQLite3Connection,
174
 
{$ENDIF}
175
 
                              TIBConnection]);
 
225
    ,TSQLite3Connection
 
226
{$ENDIF}
 
227
{$IFDEF HASIBCONNECTION}
 
228
    ,TIBConnection
 
229
{$ENDIF}
 
230
{$IFDEF HASFBADMIN}
 
231
    ,TFBAdmin
 
232
{$ENDIF}
 
233
{$IFDEF HASFBEVENT}
 
234
    ,TFBEventMonitor
 
235
{$ENDIF}
 
236
{$IFDEF HASLIBLOADER}
 
237
    ,TSQLDBLibraryLoader
 
238
{$ENDIF}
 
239
    ]);
176
240
end;
177
241
 
178
242
 
185
249
  SInterbaseDatabases = 'Interbase databases';
186
250
  SSQLStringsPropertyEditorDlgTitle = 'Editing %s';
187
251
 
 
252
  sLibraries = 'Shared libraries';
 
253
 
 
254
{ TSQLDBLibraryLoaderConnectionTypePropertyEditor }
 
255
 
 
256
function TSQLDBConnectorTypePropertyEditor.GetAttributes: TPropertyAttributes;
 
257
begin
 
258
  Result := [paMultiSelect, paSortList, paValueList, paRevertable];
 
259
end;
 
260
 
 
261
procedure TSQLDBConnectorTypePropertyEditor.GetValues(Proc: TGetStrProc);
 
262
Var
 
263
  L : TStringList;
 
264
  I : Integer;
 
265
begin
 
266
  L:=TStringList.Create;
 
267
  try
 
268
    GetConnectionList(L);
 
269
    for I:=0 to L.Count-1 do
 
270
      Proc(L[i]);
 
271
  finally
 
272
    L.Free;
 
273
  end;
 
274
end;
 
275
 
 
276
procedure TSQLDBConnectorTypePropertyEditor.SetValue(const NewValue: ansistring);
 
277
var
 
278
  Comp: TPersistent;
 
279
  Code: TCodeBuffer;
 
280
  ConnDef: TConnectionDef;
 
281
  SrcEdit: TSourceEditorInterface;
 
282
begin
 
283
  if not LazarusIDE.BeginCodeTools then
 
284
    Exit;
 
285
  SrcEdit := SourceEditorManagerIntf.ActiveEditor;
 
286
  if SrcEdit=nil then
 
287
    Exit;
 
288
  Code := TCodeBuffer(SrcEdit.CodeToolsBuffer);
 
289
  if Code = nil then
 
290
    Exit;
 
291
  Comp := GetComponent(0);
 
292
  if Comp is TSQLConnector then
 
293
  begin
 
294
    ConnDef := GetConnectionDef(NewValue);
 
295
    if Assigned(ConnDef) then
 
296
      CodeToolBoss.AddUnitToMainUsesSection(Code, ConnDef.UnitName, '');
 
297
  end;
 
298
  inherited;
 
299
end;
 
300
 
 
301
{$IFDEF HASLIBLOADER}
 
302
{ TSQLDBLibraryLoaderLibraryNamePropertyEditor }
 
303
 
 
304
function TSQLDBLibraryLoaderLibraryNamePropertyEditor.GetFilter: String;
 
305
begin
 
306
  Result := sLibraries+'|*.'+SharedSuffix;
 
307
  Result := Result+ '|'+ inherited GetFilter;
 
308
end;
 
309
{$ENDIF}
 
310
 
188
311
{ TDbfFileNamePropertyEditor }
189
312
 
190
313
function TSQLFirebirdFileNamePropertyEditor.GetFilter: String;
256
379
  Result := [paMultiSelect, paDialog, paRevertable, paReadOnly];
257
380
end;
258
381
 
259
 
{$IFDEF HASSQLPARSER}
260
382
{ TSQLSyntaxChecker }
261
383
 
262
384
procedure TSQLSyntaxChecker.CheckSQLStatement(Sender: TObject;
300
422
  IDEMessagesWindow.AddMsg(SourceFileName+' : '+Msg,'',0,Nil);
301
423
end;
302
424
 
303
 
procedure TSQLSyntaxChecker.ShowMessage(const Fmt: String;
304
 
  Args: array of const);
 
425
procedure TSQLSyntaxChecker.ShowMessage(const Fmt: String; Args: array of const);
305
426
begin
306
427
  ShowMessage(Format(Fmt,Args));
307
428
end;
379
500
 
380
501
Var
381
502
  AChecker : TSQLSyntaxChecker;
382
 
{$ENDIF HASSQLPARSER}
383
503
 
384
504
procedure Register;
385
505
begin
386
506
  RegisterPropertyEditor(TypeInfo(AnsiString),
387
507
    TIBConnection, 'DatabaseName', TSQLFirebirdFileNamePropertyEditor);
 
508
  RegisterPropertyEditor(TypeInfo(AnsiString),
 
509
    TSQLConnector, 'ConnectorType', TSQLDBConnectorTypePropertyEditor);
 
510
{$IFDEF HASLIBLOADER}
 
511
  RegisterPropertyEditor(TypeInfo(AnsiString),
 
512
    TSQLDBLibraryLoader, 'LibraryName', TSQLDBLibraryLoaderLibraryNamePropertyEditor);
 
513
  RegisterPropertyEditor(TypeInfo(AnsiString),
 
514
    TSQLDBLibraryLoader, 'ConnectionType', TSQLDBConnectorTypePropertyEditor);
 
515
{$endif}
388
516
  RegisterPropertyEditor(TStrings.ClassInfo, TSQLQuery,  'SQL'      , TSQLStringsPropertyEditor);
389
517
  RegisterPropertyEditor(TStrings.ClassInfo, TSQLQuery,  'InsertSQL', TSQLStringsPropertyEditor);
390
518
  RegisterPropertyEditor(TStrings.ClassInfo, TSQLQuery,  'DeleteSQL', TSQLStringsPropertyEditor);
393
521
  RegisterProjectFileDescriptor(TSQLFileDescriptor.Create);
394
522
 
395
523
  RegisterUnit('sqldb',@RegisterUnitSQLdb);
396
 
{$IFDEF HASSQLPARSER}
397
524
  AChecker:=TSQLSyntaxChecker.Create(Nil);
398
525
  LazarusIDE.AddHandlerOnQuickSyntaxCheck(@AChecker.CheckSource,False);
399
 
{$ENDIF HASSQLPARSER}
400
526
end;
401
527
 
402
528
{ TSQLFileDescriptor }
421
547
  Result:=SSQLScriptDesc;
422
548
end;
423
549
 
424
 
function TSQLFileDescriptor.GetResourceSource(const ResourceName: string
425
 
  ): string;
 
550
function TSQLFileDescriptor.GetResourceSource(const ResourceName: string): string;
426
551
begin
427
552
  Result:='';
428
553
end;
434
559
end;
435
560
 
436
561
initialization
437
 
 {$i registersqldb.lrs}
 
562
  {$i registersqldb.lrs}
438
563
 
439
 
{$IFDEF HASSQLPARSER}
440
564
finalization
441
565
  FreeAndNil(AChecker);
442
 
{$ENDIF HASSQLPARSER}
443
566
end.