diff options
Diffstat (limited to 'plugins/ImportTXT')
-rw-r--r-- | plugins/ImportTXT/BICQ6IP(ADO).inc | 103 | ||||
-rw-r--r-- | plugins/ImportTXT/ImportThrd.pas | 2 | ||||
-rw-r--r-- | plugins/ImportTXT/importtxt.dpr | 27 |
3 files changed, 116 insertions, 16 deletions
diff --git a/plugins/ImportTXT/BICQ6IP(ADO).inc b/plugins/ImportTXT/BICQ6IP(ADO).inc new file mode 100644 index 0000000000..b4c85e5d05 --- /dev/null +++ b/plugins/ImportTXT/BICQ6IP(ADO).inc @@ -0,0 +1,103 @@ +{$IFDEF BIN_IMPORT_}
+
+var
+ QR1: TADOQuery;
+
+var
+ OneContact: boolean;
+ flags: integer;
+ timestamp: LongWord;
+ Msg: AnsiString;
+ ADOConnection:TADOConnection;
+
+function FindUIDinDB(too: string): string;
+var
+ QR2: TADOQuery;
+begin
+ QR2 := TADOQuery.Create(nil);
+ QR2.Connection := ADOConnection;
+ QR2.SQL.Text := 'select to, UID from ChatHistory WHERE to=' + too;
+ QR2.Open;
+ QR2.First;
+ result := QR2.FieldByName('UID').AsString;
+ QR2.Close;
+ QR2.Free;
+end;
+
+{$ELSE}
+
+begin
+ DoUnMapFile;
+ OneContact := (DContact.hContact <> 0) and (DContact.hContact <> INVALID_HANDLE_VALUE);
+ try
+// coInitialize(nil);
+ ADOConnection:=TADOConnection.Create(nil);
+ ADOConnection.Connected:=false;
+ ADOConnection.LoginPrompt:=false;
+ ADOConnection.Provider:='Microsoft.Jet.OLEDB.4.0';
+ ADOConnection.ConnectionString :=
+ 'User ID=Admin;' +
+ 'Data Source=' + FileName +
+ ';Mode=Share Deny None;' +
+ 'Extended Properties="";' +
+ 'Locale Identifier=1033;' +
+ 'Persist Security Info=False;';
+
+ ADOConnection.Connected:=true;
+
+ QR1 := TADOQuery.Create(nil);
+ QR1.Connection := ADOConnection;
+ QR1.SQL.Text := 'SELECT Messages.from, date, to, type, subType, subject FROM Messages';
+ QR1.Open;
+ if (QR1.FieldCount = 7) then
+ begin
+ DoMessage(ITXT_THREAD_START, 0, 0);
+ QR1.First;
+ DoMessage(ITXT_THREAD_MAXPROGRESS, 0, QR1.RecordCount);
+ While not QR1.EOF do
+ begin
+ try
+ if (QR1.FieldByName('type').AsString = 'Text') and
+ (QR1.FieldByName('subType').AsString = 'IM') then
+ begin
+ UIDStr := FindUIDinDB(QR1.FieldByName('to').AsString);
+ if not OneContact then
+ begin
+ DContact.ContactUID := UIDStr;
+ TryDetermContact(DContact);
+ end;
+ if (DContact.hContact <> 0) and
+ (DContact.hContact <> INVALID_HANDLE_VALUE) then
+ begin
+ if QR1.Fields[1].AsString = '' then
+ flags := DBEF_READ or DBEF_UTF or DBEF_SENT
+ else
+ flags := DBEF_READ or DBEF_UTF;
+ timestamp := DateTimeToTimeStamp(QR1.FieldByName('date').AsDateTime - 693594);
+ Msg := QR1.FieldByName('subject').AsString;
+ tempstr := ANSIToUTF8(PAnsiChar(Msg), tempstr, cp);
+ Msg := tempstr;
+ FreeMem(tempstr);
+ AddMsgToDB(DContact.hContact, flags, timestamp, Msg, AddedMessages, Duplicates);
+ end;
+ end;
+ except
+ ShowException(ExceptObject, ExceptAddr)
+ end;
+ QR1.Next;
+ DoMessage(ITXT_THREAD_PROGRESS, QR1.RecNo, 0);
+ end; // for
+ end
+ else
+ begin
+ s := WideFormat(TranslateWideString('Its not %s file'), ['ICQ6 mdb']);
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ end;
+ finally
+ QR1.Close;
+ QR1.Free;
+ ADOConnection.Close;
+ ADOConnection.Free;
+ end;
+end;
+{$ENDIF}
diff --git a/plugins/ImportTXT/ImportThrd.pas b/plugins/ImportTXT/ImportThrd.pas index 245276c040..2742ccd63e 100644 --- a/plugins/ImportTXT/ImportThrd.pas +++ b/plugins/ImportTXT/ImportThrd.pas @@ -12,7 +12,7 @@ uses general,
ImportT,
ImportTU,
- KOLEdb;
+ KOLEdb {ADODB if want to use ADO};
const
ITXT_THREAD_BASE = $8000 + $2000; // WM_APP + $2000
diff --git a/plugins/ImportTXT/importtxt.dpr b/plugins/ImportTXT/importtxt.dpr index 5fea1c6a2b..5cc6d12864 100644 --- a/plugins/ImportTXT/importtxt.dpr +++ b/plugins/ImportTXT/importtxt.dpr @@ -42,20 +42,7 @@ uses {$R imptxt_ver.res}
-const
- PluginInfo:TPLUGININFOEX=(
- cbSize :sizeof(TPLUGININFOEX);
- shortName :'Import TXT';
- version :$0000010A;
- description:'Imports history saved in TXT files from other clients.';
- author :'Abyss';
- authorEmail:'abyss.andrey@gmail.com';
- copyright :'(C)2008 Abyss';
- homepage :'none';
- flags :UNICODE_AWARE;
- replacesDefaultModule:0;
- uuid:'{6F376B33-D3F4-4c4f-A96B-77DA08043B06}';
- );
+const MIID_IMPORTTEXT:TGUID = '{6F376B33-D3F4-4c4f-A96B-77DA08043B06}';
// Updater compatibility data
const
@@ -78,8 +65,18 @@ var function MirandaPluginInfoEx(mirandaVersion:DWORD):PPLUGININFOEX; cdecl;
begin
+ PluginInfo.cbSize :=sizeof(TPLUGININFOEX);
+ PluginInfo.shortName :='Import TXT';
+ PluginInfo.version :=$0000010A;
+ PluginInfo.description:='Imports history saved in TXT files from other clients.';
+ PluginInfo.author :='Abyss';
+ PluginInfo.authorEmail:='abyss.andrey@gmail.com';
+ PluginInfo.copyright :='(C)2008 Abyss';
+ PluginInfo.homepage :='none';
+ PluginInfo.flags :=UNICODE_AWARE;
+ PluginInfo.uuid :=MIID_IMPORTTEXT;
+
result := @PluginInfo;
- // PluginInfo.cbSize:=SizeOf(TPLUGININFOEX);
end;
function ContactMenuCommand(wParam: wParam; lParam: lParam): int_ptr; cdecl;
|