summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Kulakov <panda75@bk.ru>2012-07-03 07:22:09 +0000
committerAlexey Kulakov <panda75@bk.ru>2012-07-03 07:22:09 +0000
commit8b8845c8e142c2e70bc0c2785ddf3a91ad3f84bd (patch)
tree58d80918e28651c678069aa2ee768f801eca74db
parent980bcaff693a86971750d6e9ffc8ba1e561b8b3a (diff)
New core adaptation (Delphi 7 normal compilation)
API headers update git-svn-id: http://svn.miranda-ng.org/main/trunk@731 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/ImportTXT/BICQ5IP.inc200
-rw-r--r--plugins/ImportTXT/BICQ6IP.inc166
-rw-r--r--plugins/ImportTXT/BRMSIP.inc143
-rw-r--r--plugins/ImportTXT/BbayanIP.inc141
-rw-r--r--plugins/ImportTXT/BmContactIP.inc102
-rw-r--r--plugins/ImportTXT/BqhfIP.inc231
-rw-r--r--plugins/ImportTXT/FileDlgs.pas18
-rw-r--r--plugins/ImportTXT/General.pas858
-rw-r--r--plugins/ImportTXT/ImpDlgRes.inc21
-rw-r--r--plugins/ImportTXT/ImpWizRes.inc42
-rw-r--r--plugins/ImportTXT/ImportT.pas45
-rw-r--r--plugins/ImportTXT/ImportTU.pas290
-rw-r--r--plugins/ImportTXT/ImportThrd.pas1024
-rw-r--r--plugins/ImportTXT/ImportTxtWiz.pas663
-rw-r--r--plugins/ImportTXT/importtxt.dpr189
-rw-r--r--plugins/ImportTXT/importtxtdlg.pas366
-rw-r--r--plugins/Pascal_Headers/m_api.pas40
-rw-r--r--plugins/Pascal_Headers/m_core.inc9
-rw-r--r--plugins/Pascal_Headers/m_helpers.inc10
-rw-r--r--plugins/Pascal_Headers/m_idle.inc15
20 files changed, 2329 insertions, 2244 deletions
diff --git a/plugins/ImportTXT/BICQ5IP.inc b/plugins/ImportTXT/BICQ5IP.inc
index 581085ece6..f86762451b 100644
--- a/plugins/ImportTXT/BICQ5IP.inc
+++ b/plugins/ImportTXT/BICQ5IP.inc
@@ -1,112 +1,122 @@
-{$ifdef BIN_IMPORT_}
+{$IFDEF BIN_IMPORT_}
+
var
- XI:XML_API_W;
- rhxml:HXML;
- curxml:HXML;
- chldxml:HXML;
- ptxt:PWideChar;
- txtlen:int;
- ic,tm:integer;
- res:LongBool;
+ XI: XML_API_W;
+ rhxml: HXML;
+ curxml: HXML;
+ chldxml: HXML;
+ ptxt: PWideChar;
+ txtlen: int;
+ ic, tm: integer;
+ res: LongBool;
+
+{$ELSE}
-{$else}
begin
- If pluginLink^.ServiceExists(MS_SYSTEM_GET_XI)>0 then
- begin
- XI.cbSize:=SizeOf(XML_API_W);
- res:=longbool(pluginLink^.CallService(MS_SYSTEM_GET_XI,0,Int(@XI)));
+ If ServiceExists(MS_SYSTEM_GET_XI) > 0 then
+ begin
+ XI.cbSize := SizeOf(XML_API_W);
+ res := LongBool(CallService(MS_SYSTEM_GET_XI, 0, int(@XI)));
if not res then
- begin
- XI.cbSize:=SizeOf(XML_API_W)-4;
- res:=longbool(pluginLink^.CallService(MS_SYSTEM_GET_XI,0,Int(@XI)));
+ begin
+ XI.cbSize := SizeOf(XML_API_W) - 4;
+ res := LongBool(CallService(MS_SYSTEM_GET_XI, 0, int(@XI)));
if not res then
- begin
- s:=TranslateWideString('Error at initialization XML parser');
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
+ begin
+ s := TranslateWideString('Error at initialization XML parser');
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
exit;
- end;
- end;
- end
- else
- begin
- s:=TranslateWideString('Your version of Miranda don''t support XML parsing');
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
+ end;
+ end;
+ end
+ else
+ begin
+ s := TranslateWideString('Your version of Miranda don''t support XML parsing');
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
exit;
- end;
- if (DContact.hContact=0) or (DContact.hContact=INVALID_HANDLE_VALUE) then
- if (fContact.hContact<>0) and (fContact.hContact<>INVALID_HANDLE_VALUE) then
- DContact:=fContact;
- if (DContact.hContact<>0) and (DContact.hContact<>INVALID_HANDLE_VALUE) then
- begin
- proto:=GetContactProto(DContact.hContact);
- DoMessage(ITXT_THREAD_DEST_CONTACT,DContact.hContact,0);
- DoMessage(ITXT_THREAD_START,0,0);
- GetMem(ptxt,SizeOf(WideChar)*FileLen+2);
+ end;
+ if (DContact.hContact = 0) or (DContact.hContact = INVALID_HANDLE_VALUE) then
+ if (fContact.hContact <> 0) and (fContact.hContact <> INVALID_HANDLE_VALUE) then
+ DContact := fContact;
+ if (DContact.hContact <> 0) and (DContact.hContact <> INVALID_HANDLE_VALUE) then
+ begin
+ proto := GetContactProto(DContact.hContact);
+ DoMessage(ITXT_THREAD_DEST_CONTACT, DContact.hContact, 0);
+ DoMessage(ITXT_THREAD_START, 0, 0);
+ GetMem(ptxt, SizeOf(WideChar) * FileLen + 2);
try
- ptxt:=UTF8toWide(pFileText,ptxt,SizeOf(WideChar)*FileLen+2);
- ptxt[FileLen+1]:=#0000;
- rhxml:=XI.parseString(ptxt,@txtlen,'root');
+ ptxt := UTF8toWide(pFileText, ptxt, SizeOf(WideChar) * FileLen + 2);
+ ptxt[FileLen + 1] := #0000;
+ rhxml := XI.parseString(ptxt, @txtlen, 'root');
finally
- freemem(ptxt);
+ freemem(ptxt);
end;
- if (rhxml=0) then exit;
- DoMessage(ITXT_THREAD_MAXPROGRESS,0,xi.getChildCount(rhxml));
- chldxml:=xi.getFirstChild(rhxml);
- if xi.getName(chldxml)='version' then
+ if (rhxml = 0) then
+ exit;
+ DoMessage(ITXT_THREAD_MAXPROGRESS, 0, XI.getChildCount(rhxml));
+ chldxml := XI.getFirstChild(rhxml);
+ if XI.getName(chldxml) = 'version' then
+ begin
+ ic := 0;
+ curxml := XI.getNextChild(rhxml, 'event', @ic);
+ while (curxml <> 0) do
begin
- ic:=0;
- curxml:=xi.getNextChild(rhxml,'event',@ic);
- while (curxml<>0) do
- begin
- fillchar(dbei,sizeof(dbei),0);
- dbei.cbSize:=sizeof(dbei);
- dbei.szModule:=PChar(proto);
- if TryStrToInt(xi.getText(xi.getChildByPath(curxml,'time',false)),tm) then dbei.timestamp:=tm;
- if xi.getText(xi.getChildByPath(curxml,'incoming',false))='Yes' then dbei.flags:=DBEF_READ
- else dbei.flags:=DBEF_SENT or DBEF_READ;
- if isMirandaUnicode then dbei.flags:=dbei.flags or DBEF_UTF;
+ fillchar(dbei, SizeOf(dbei), 0);
+ dbei.cbSize := SizeOf(dbei);
+ dbei.szModule := PAnsiChar(proto);
+ if TryStrToInt(XI.getText(XI.getChildByPath(curxml, 'time', false)), tm)
+ then
+ dbei.timestamp := tm;
+ if XI.getText(XI.getChildByPath(curxml, 'incoming', false)) = 'Yes' then
+ dbei.flags := DBEF_READ or DBEF_UTF
+ else
+ dbei.flags := DBEF_READ or DBEF_UTF or DBEF_SENT;
- if xi.getText(xi.getChildByPath(curxml,'type',false))^='2' then
- begin
- s:=xi.getText(xi.getChildByPath(curxml,'text',false))+': '+
- xi.getText(xi.getChildByPath(curxml,'data',false));
- dbei.eventType:= EVENTTYPE_URL;
- end
- else
- begin
- s:=xi.getText(xi.getChildByPath(curxml,'text',false));
- dbei.eventType:= EVENTTYPE_MESSAGE;
- end;
- try
- if IsMirandaUnicode then tempstr:=WidetoUTF8(PWideChar(s),tempstr)
- else tempstr:=WideToANSI(PWideChar(s),tempstr,cp);
- dbei.cbBlob:=lstrlen(tempstr)+1;
- dbei.pBlob:=PByte(tempstr);
- if not IsDuplicateEvent(DContact.hContact,dbei) then
- if pluginLink^.CallService(MS_DB_EVENT_ADD, wParam(DContact.hContact), lParam(@dbei))<>0 then Inc(AddedMessages)
- else begin
- s:= 'Error adding message to DB';
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0); break; end
+ if XI.getText(XI.getChildByPath(curxml, 'type', false))^ = '2' then
+ begin
+ s := XI.getText(XI.getChildByPath(curxml, 'text', false)) + ': ' +
+ XI.getText(XI.getChildByPath(curxml, 'data', false));
+ dbei.eventType := EVENTTYPE_URL;
+ end
+ else
+ begin
+ s := XI.getText(XI.getChildByPath(curxml, 'text', false));
+ dbei.eventType := EVENTTYPE_MESSAGE;
+ end;
+ try
+ tempstr := WidetoUTF8(PWideChar(s), tempstr);
+ dbei.cbBlob := lstrlena(tempstr) + 1;
+ dbei.pBlob := PByte(tempstr);
+ if not IsDuplicateEvent(DContact.hContact, dbei) then
+ if CallService(MS_DB_EVENT_ADD, wParam(DContact.hContact), lParam(@dbei)) <> 0 then
+ Inc(AddedMessages)
+ else
+ begin
+ s := 'Error adding message to DB';
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ break;
+ end
- else Inc(Duplicates);
+ else
+ Inc(Duplicates);
- finally
- FreeMem(tempstr);
- curxml:=xi.getNextChild(rhxml,'event',@ic);
- DoMessage(ITXT_THREAD_PROGRESS,ic,0);
- end;
+ finally
+ freemem(tempstr);
+ curxml := XI.getNextChild(rhxml, 'event', @ic);
+ DoMessage(ITXT_THREAD_PROGRESS, ic, 0);
end;
- end
- else
- begin
- s:=WideFormat(TranslateWideString('Its not %s file'),['ICQ5']);
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
end;
- end
- else
- begin
- s:=TranslateWideString('Can''t determine destination contact');
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
- end;
+ end
+ else
+ begin
+ s := WideFormat(TranslateWideString('Its not %s file'), ['ICQ5']);
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ end;
+ end
+ else
+ begin
+ s := TranslateWideString('Can''t determine destination contact');
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ end;
end;
-{$endif} \ No newline at end of file
+{$ENDIF}
diff --git a/plugins/ImportTXT/BICQ6IP.inc b/plugins/ImportTXT/BICQ6IP.inc
index af8c197e74..f3169374a3 100644
--- a/plugins/ImportTXT/BICQ6IP.inc
+++ b/plugins/ImportTXT/BICQ6IP.inc
@@ -1,91 +1,93 @@
-{$ifdef BIN_IMPORT_}
-var DS: PDataSource;
- SS: PSession;
- QR1: PQuery;
+{$IFDEF BIN_IMPORT_}
var
- OneContact:boolean;
- flags:integer;
- timestamp:LongWord;
- Msg:string;
+ DS: PDataSource;
+ SS: PSession;
+ QR1: PQuery;
-function FindUIDinDB(too:string):string;
-var QR2:PQuery;
+var
+ OneContact: boolean;
+ flags: integer;
+ timestamp: LongWord;
+ Msg: AnsiString;
+
+function FindUIDinDB(too: string): string;
+var
+ QR2: PQuery;
begin
- QR2:= NewQuery( SS );
- QR2.Text := 'select to, UID from ChatHistory WHERE to='+too;
- QR2.Open;
- QR2.First;
- result:=QR2.FieldByNameAsStr['UID'];
- QR2.Free;
+ QR2 := NewQuery(SS);
+ QR2.Text := 'select to, UID from ChatHistory WHERE to=' + too;
+ QR2.Open;
+ QR2.First;
+ result := QR2.FieldByNameAsStr['UID'];
+ QR2.Free;
end;
-{$else}
+{$ELSE}
+
begin
- DoUnMapFile;
- OneContact:=(DContact.hContact<>0) and (DContact.hContact<>INVALID_HANDLE_VALUE);
- try
- DS := NewDataSource( 'Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;' +
- 'Data Source='+FileName+
- ';Mode=Share Deny None;' +
- 'Extended Properties="";' +
- 'Locale Identifier=1033;' +
- 'Persist Security Info=False;');
- SS := NewSession( DS );
- QR1 := NewQuery( SS );
- QR1.Text:= 'SELECT Messages.from, date, to, type, subType, subject FROM Messages';
- QR1.Open;
- if (QR1.ColCount=7) then
- begin
- DoMessage(ITXT_THREAD_START,0,0);
- QR1.First;
- DoMessage(ITXT_THREAD_MAXPROGRESS,0,QR1.RowCount);
- While not QR1.EOF do
- begin
- try
- if (QR1.SFieldByName[ 'type' ]='Text') and
- (QR1.SFieldByName[ 'subType' ]='IM') then
- begin
- UIDStr:=FindUIDinDB(QR1.FieldByNameAsStr[ 'to' ]);
- 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.SField[ 1 ]='' then flags:=DBEF_SENT or DBEF_READ
- else flags:=DBEF_READ;
- if IsMirandaUnicode then flags:=flags or DBEF_UTF;
- timestamp:=DateTimeToTimeStamp(QR1.DFieldByName['date']-693594);
- Msg:=QR1.SFieldByName['subject'];
- if IsMirandaUnicode then
- begin
- tempstr:=ANSIToUTF8(PAnsiChar(Msg),tempstr,cp);
- Msg:=tempstr;
- FreeMem(tempstr);
- end;
- AddMsgToDB(DContact.hContact,flags,timestamp,Msg,AddedMessages,Duplicates);
- end;
- end;
- except
- ShowException(ExceptObject,ExceptAddr)
+ DoUnMapFile;
+ OneContact := (DContact.hContact <> 0) and (DContact.hContact <> INVALID_HANDLE_VALUE);
+ try
+ DS := NewDataSource('Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;' +
+ 'Data Source=' + FileName +
+ ';Mode=Share Deny None;' +
+ 'Extended Properties="";' +
+ 'Locale Identifier=1033;' +
+ 'Persist Security Info=False;');
+ SS := NewSession(DS);
+ QR1 := NewQuery(SS);
+ QR1.Text := 'SELECT Messages.from, date, to, type, subType, subject FROM Messages';
+ QR1.Open;
+ if (QR1.ColCount = 7) then
+ begin
+ DoMessage(ITXT_THREAD_START, 0, 0);
+ QR1.First;
+ DoMessage(ITXT_THREAD_MAXPROGRESS, 0, QR1.RowCount);
+ While not QR1.EOF do
+ begin
+ try
+ if (QR1.SFieldByName['type'] = 'Text') and
+ (QR1.SFieldByName['subType'] = 'IM') then
+ begin
+ UIDStr := FindUIDinDB(QR1.FieldByNameAsStr['to']);
+ 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.SField[1] = '' then
+ flags := DBEF_READ or DBEF_UTF or DBEF_SENT
+ else
+ flags := DBEF_READ or DBEF_UTF;
+ timestamp := DateTimeToTimeStamp(QR1.DFieldByName['date'] - 693594);
+ Msg := QR1.SFieldByName['subject'];
+ 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.CurIndex, 0);
+ end; // for
+ end
+ else
+ begin
+ s := WideFormat(TranslateWideString('Its not %s file'), ['ICQ6 mdb']);
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
end;
- QR1.Next;
- DoMessage(ITXT_THREAD_PROGRESS,QR1.CurIndex,0);
- end; //for
- end
- else
- begin
- s:=WideFormat(TranslateWideString('Its not %s file'),['ICQ6 mdb']);
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
- end;
- finally
- DS.Free;
- DS := nil;
- SS := nil;
- QR1 := nil;
- end;
+ finally
+ DS.Free;
+ DS := nil;
+ SS := nil;
+ QR1 := nil;
+ end;
end;
-{$endif}
-
+{$ENDIF}
diff --git a/plugins/ImportTXT/BRMSIP.inc b/plugins/ImportTXT/BRMSIP.inc
index 552a98af3b..8010a8973c 100644
--- a/plugins/ImportTXT/BRMSIP.inc
+++ b/plugins/ImportTXT/BRMSIP.inc
@@ -1,77 +1,86 @@
-{$ifdef BIN_IMPORT_}
-var rsz:integer;
+{$IFDEF BIN_IMPORT_}
+var
+ rsz: integer;
+
+{$ELSE}
-{$else}
begin
- pt:=integer(pFileText);
- i:=0;
- if FileLen>=$30 then
- if (StrLComp(PChar(pt),'midp-rms',8)=0) then
- begin
- if FileLen>=$48 then
- if (RLInteger(pt+$40)=$48) then
- begin
- fsz:=RLInteger(pt+$44);
- i:=$48;
- end;
- if (RLInteger(pt+$28)=$30) then
- begin
- fsz:=RLInteger(pt+$2C);
- i:=$30;
- end;
+ pt := uint_ptr(pFileText);
+ i := 0;
+ if FileLen >= $30 then
+ if (StrLComp(PAnsiChar(pt), 'midp-rms', 8) = 0) then
+ begin
+ if FileLen >= $48 then
+ if (RLInteger(pt + $40) = $48) then
+ begin
+ fsz := RLInteger(pt + $44);
+ i := $48;
+ end;
+ if (RLInteger(pt + $28) = $30) then
+ begin
+ fsz := RLInteger(pt + $2C);
+ i := $30;
+ end;
+
+ if (DContact.hContact = 0) or (DContact.hContact = INVALID_HANDLE_VALUE) then
+ if (fContact.hContact <> 0) and (fContact.hContact <> INVALID_HANDLE_VALUE) then
+ DContact := fContact;
+ if (DContact.hContact <> 0) and (DContact.hContact <> INVALID_HANDLE_VALUE) then
+ begin
+ proto := GetContactProto(DContact.hContact);
+ DoMessage(ITXT_THREAD_DEST_CONTACT, DContact.hContact, 0);
+ DoMessage(ITXT_THREAD_START, 0, 0);
+ DoMessage(ITXT_THREAD_MAXPROGRESS, 0, fsz);
+ while Cardinal(i) < fsz do
+ begin
+ fillchar(dbei, sizeof(dbei), 0);
+ dbei.cbSize := sizeof(dbei);
+ dbei.szModule := PAnsiChar(proto);
+ rsz := RLInteger(pt + i + $08);
+ if PByte(pt + i + $10)^ = $00 then
+ dbei.flags := DBEF_READ or DBEF_UTF
+ else
+ dbei.flags := DBEF_READ or DBEF_UTF or DBEF_SENT;
+ // в файлах лежат в utf8 и импортируются без изменений
+ dbei.eventType := EVENTTYPE_MESSAGE;
+ dbei.cbBlob := RLWord(pt + i + $13 + RLWord(pt + i + $11));
+ dbei.pBlob := Pointer(pt + i + $13 + RLWord(pt + i + $11) + $2);
+ dbei.timestamp := StrToTimeStamp
+ (Pointer(uint_ptr(pt + i) + $13 + RLWord(pt + i + $11) + $4 + dbei.cbBlob),
+ RLWord(uint_ptr(pt + i) + $13 + RLWord(pt + i + $11) + $2 + dbei.cbBlob));
+ inc(dbei.cbBlob);
- if (DContact.hContact=0) or (DContact.hContact=INVALID_HANDLE_VALUE) then
- if (fContact.hContact<>0) and (fContact.hContact<>INVALID_HANDLE_VALUE) then
- DContact:=fContact;
- if (DContact.hContact<>0) and (DContact.hContact<>INVALID_HANDLE_VALUE) then
- begin
- proto:=GetContactProto(DContact.hContact);
- DoMessage(ITXT_THREAD_DEST_CONTACT,DContact.hContact,0);
- DoMessage(ITXT_THREAD_START,0,0);
- DoMessage(ITXT_THREAD_MAXPROGRESS,0,fsz);
- while i<fsz do
- begin
- with dbei do
- begin
- fillchar(dbei,sizeof(dbei),0);
- cbSize:=sizeof(dbei);
- szModule:=PChar(proto);
- rsz:= RLInteger(pt+i+$08);
- if PByte(pt+i+$10)^=$00 then flags:=0
- else flags:=DBEF_SENT;
- flags:=flags or DBEF_READ or DBEF_UTF; //в файлах лежат в utf8 и импортируются без изменений
- eventType:= EVENTTYPE_MESSAGE;
- cbBlob:=RLWord(pt+i+$13+RLWord(pt+i+$11));
- pBlob:=Pointer(pt+i+$13+RLWord(pt+i+$11)+$2);
- timestamp:=StrToTimeStamp(pointer(pt+i+$13+RLWord(pt+i+$11)+$4+cbBlob),RLWord(pt+i+$13+RLWord(pt+i+$11)+$2+cbBlob));
- inc(cbBlob);
- end;
- try
- if not IsDuplicateEvent(DContact.hContact,dbei) then
- if pluginLink^.CallService(MS_DB_EVENT_ADD, wParam(DContact.hContact), lParam(@dbei))<>0 then Inc(AddedMessages)
- else begin
- s:= 'Error adding message to DB';
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0); break; end
+ try
+ if not IsDuplicateEvent(DContact.hContact, dbei) then
+ if CallService(MS_DB_EVENT_ADD, wParam(DContact.hContact), lParam(@dbei))<>0 then
+ inc(AddedMessages)
+ else
+ begin
+ s := 'Error adding message to DB';
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ break;
+ end
- else Inc(Duplicates);
- finally
- inc(i,rsz);
+ else
+ inc(Duplicates);
+ finally
+ inc(i, rsz);
+ end;
+ DoMessage(ITXT_THREAD_PROGRESS, i, 0);
end;
- DoMessage(ITXT_THREAD_PROGRESS,i,0);
- end;
- end
- else
- begin
- s:=TranslateWideString('Can''t determine destination contact');
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
- end;
+ end
+ else
+ begin
+ s := TranslateWideString('Can''t determine destination contact');
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ end;
end
- else
+ else
begin
- s:=WideFormat(TranslateWideString('Its not %s file'),['midp-rms']);
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
+ s := WideFormat(TranslateWideString('Its not %s file'), ['midp-rms']);
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
end
- else //file len
+ else // file len
end;
-{$endif}
+{$ENDIF}
diff --git a/plugins/ImportTXT/BbayanIP.inc b/plugins/ImportTXT/BbayanIP.inc
index b37892fbdc..00d6de054a 100644
--- a/plugins/ImportTXT/BbayanIP.inc
+++ b/plugins/ImportTXT/BbayanIP.inc
@@ -1,77 +1,82 @@
-{$ifdef BIN_IMPORT_}
-var j:integer;
-{$else}
+{$IFDEF BIN_IMPORT_}
+
+var
+ j: integer;
+{$ELSE}
+
begin
- pt:=integer(pFileText);
- if FileLen>=10 then
- if true {(PWORD(pt)^=$4248) and (PDWORD(pt+2)^=$FFFFFFFF)} then
+ pt := uint_ptr(pFileText);
+ if FileLen >= 10 then
+ if true { (PWORD(pt)^=$4248) and (PDWORD(pt+2)^=$FFFFFFFF) } then
begin
- //смотрим есть ли у нас контакт назначения
- if (DContact.hContact=0) or (DContact.hContact=INVALID_HANDLE_VALUE) then
- if (fContact.hContact<>0) and (fContact.hContact<>INVALID_HANDLE_VALUE) then
- DContact:=fContact;
- if (DContact.hContact<>0) and (DContact.hContact<>INVALID_HANDLE_VALUE) then
- begin
- proto:=GetContactProto(DContact.hContact);
- DoMessage(ITXT_THREAD_DEST_CONTACT,DContact.hContact,0);
- DoMessage(ITXT_THREAD_START,0,0);
- fsz:=FileLen-2; //размер данных в файле
- DoMessage(ITXT_THREAD_MAXPROGRESS,0,fsz);
- inc(pt,2);
- i:=0;
- while i<fsz do
- begin
- with dbei do
- begin
- fillchar(dbei,sizeof(dbei),0);
- cbSize:=sizeof(dbei);
- szModule:=PChar(proto);
- timestamp:=ImportTU.TimeStamp(
- RLWORD(pt+i+5),
- PByte(pt+i+4)^,
- PByte(pt+i+3)^,
- PByte(pt+i)^,
- PByte(pt+i+1)^,
- PByte(pt+i+2)^);
- if PByte(pt+i+$7)^=$00 then flags:=DBEF_READ
- else flags:=DBEF_SENT or DBEF_READ;
- eventType:= EVENTTYPE_MESSAGE;
- cbBlob:=(RLWORD(pt+i+$8)+1);
- s:='';
- for j:=0 to RLWORD(pt+i+$8) do
- s:=s+WideChar(RLWORD(pt+i+$0A+(j*2)));
- if IsMirandaUnicode then
+ // смотрим есть ли у нас контакт назначения
+ if (DContact.hContact = 0) or (DContact.hContact = INVALID_HANDLE_VALUE) then
+ if (fContact.hContact <> 0) and (fContact.hContact <> INVALID_HANDLE_VALUE) then
+ DContact := fContact;
+ if (DContact.hContact <> 0) and (DContact.hContact <> INVALID_HANDLE_VALUE) then
+ begin
+ proto := GetContactProto(DContact.hContact);
+ DoMessage(ITXT_THREAD_DEST_CONTACT, DContact.hContact, 0);
+ DoMessage(ITXT_THREAD_START, 0, 0);
+ fsz := FileLen - 2; // размер данных в файле
+ DoMessage(ITXT_THREAD_MAXPROGRESS, 0, fsz);
+ inc(pt, 2);
+ i := 0;
+ while Cardinal(i) < fsz do
+ begin
+ with dbei do
+ begin
+ fillchar(dbei, sizeof(dbei), 0);
+ dbei.cbSize := sizeof(dbei);
+ dbei.szModule := PAnsiChar(proto);
+ dbei.timestamp := ImportTU.timestamp(
+ RLWORD(pt + i + 5),
+ PByte(pt + i + 4)^,
+ PByte(pt + i + 3)^,
+ PByte(pt + i)^,
+ PByte(pt + i + 1)^,
+ PByte(pt + i + 2)^);
+
+ if PByte(pt + i + $7)^ = $00 then
+ dbei.flags := DBEF_READ or DBEF_UTF
+ else
+ dbei.flags := DBEF_READ or DBEF_UTF or DBEF_SENT;
+ dbei.eventType := EVENTTYPE_MESSAGE;
+ dbei.cbBlob := (RLWORD(pt + i + $8) + 1) * sizeof(WideChar);
+ s := '';
+ for j := 0 to RLWORD(pt + i + $8) do
+ s := s + WideChar(RLWORD(pt + i + $0A + (j * 2)));
+
+ dbei.pBlob := PByte(WideToUTF8(PWideChar(s), PAnsiChar(pBlob)));
+ end;
+ if not IsDuplicateEvent(DContact.hContact, dbei) then
+ if CallService(MS_DB_EVENT_ADD, wParam(DContact.hContact), lParam(@dbei)) <> 0 then
+ inc(AddedMessages)
+ else
begin
- flags:=flags or DBEF_UTF;
- cbBlob:=cbBlob*SizeOf(WideChar);
- pBlob:=PByte(WideToUTF8(PWideChar(S),PChar(pBlob)));
+ s := 'Error adding message to DB';
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ break;
end
- else
- pBlob:=PByte(WideToANSI(PWideChar(S),PChar(pBlob),cp));
- end;
- if not IsDuplicateEvent(DContact.hContact,dbei) then
- if pluginLink^.CallService(MS_DB_EVENT_ADD, wParam(DContact.hContact), lParam(@dbei))<>0 then Inc(AddedMessages)
- else begin
- s:= 'Error adding message to DB';
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0); break; end
- else Inc(Duplicates);
- inc(i,dbei.cbBlob+$0C);
- FreeMem(dbei.pBlob);
- DoMessage(ITXT_THREAD_PROGRESS,i,0);
- end;
- end
- else
- begin
- s:=TranslateWideString('Can''t determine destination contact');
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
- end;
+ else
+ inc(Duplicates);
+ inc(i, dbei.cbBlob + $0C);
+ FreeMem(dbei.pBlob);
+ DoMessage(ITXT_THREAD_PROGRESS, i, 0);
+ end;
+ end
+ else
+ begin
+ s := TranslateWideString('Can''t determine destination contact');
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ end;
end
- else
+ else
begin
- s:=WideFormat(TranslateWideString('Its not %s file'),['bayanICQ']);
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
+ s := WideFormat(TranslateWideString('Its not %s file'), ['bayanICQ']);
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
end
- else //file len
+ else // file len
end;
-{$endif}
+{$ENDIF}
diff --git a/plugins/ImportTXT/BmContactIP.inc b/plugins/ImportTXT/BmContactIP.inc
index e4fe59165e..a582d26d35 100644
--- a/plugins/ImportTXT/BmContactIP.inc
+++ b/plugins/ImportTXT/BmContactIP.inc
@@ -1,58 +1,60 @@
-{$ifdef BIN_IMPORT_}
+{$IFDEF BIN_IMPORT_}
+{$ELSE}
-{$else}
begin
- pt:=integer(pFileText);
- if FileLen>=10 then
- if (PWORD(pt)^=$4248) and (PDWORD(pt+2)^=$FFFFFFFF) then
+ pt := uint_ptr(pFileText);
+ if FileLen >= 10 then
+ if (PWORD(pt)^ = $4248) and (PDWORD(pt + 2)^ = $FFFFFFFF) then
begin
- //смотрим есть ли у нас контакт назначения
- if (DContact.hContact=0) or (DContact.hContact=INVALID_HANDLE_VALUE) then
- if (fContact.hContact<>0) and (fContact.hContact<>INVALID_HANDLE_VALUE) then
- DContact:=fContact;
- if (DContact.hContact<>0) and (DContact.hContact<>INVALID_HANDLE_VALUE) then
- begin
- proto:=GetContactProto(DContact.hContact);
- DoMessage(ITXT_THREAD_DEST_CONTACT,DContact.hContact,0);
- DoMessage(ITXT_THREAD_START,0,0);
- fsz:=PDWORD(pt+6)^; //размер данных в файле
- DoMessage(ITXT_THREAD_MAXPROGRESS,0,fsz);
- inc(pt,10);
- i:=0;
- while i<fsz do
- begin
- with dbei do
- begin
- cbSize:=PInteger(pt+i)^;
- szModule:=PChar(proto);
- timestamp:=PDWORD(pt+i+$08)^;
- flags:=PDWORD(pt+i+$0C)^;
- eventtype:=PDWORD(pt+i+$10)^;
- cbBlob:=PDWORD(pt+i+$14)^;
- pBlob:=PBYTE(pt+i+cbSize);
- end;
- if not IsDuplicateEvent(DContact.hContact,dbei) then
- if pluginLink^.CallService(MS_DB_EVENT_ADD, wParam(DContact.hContact), lParam(@dbei))<>0 then Inc(AddedMessages)
- else begin
- s:= 'Error adding message to DB';
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0); break; end
+ // смотрим есть ли у нас контакт назначения
+ if (DContact.hContact = 0) or (DContact.hContact = INVALID_HANDLE_VALUE) then
+ if (fContact.hContact <> 0) and (fContact.hContact <> INVALID_HANDLE_VALUE) then
+ DContact := fContact;
+ if (DContact.hContact <> 0) and (DContact.hContact <> INVALID_HANDLE_VALUE) then
+ begin
+ proto := GetContactProto(DContact.hContact);
+ DoMessage(ITXT_THREAD_DEST_CONTACT, DContact.hContact, 0);
+ DoMessage(ITXT_THREAD_START, 0, 0);
+ fsz := PDWORD(pt + 6)^; // размер данных в файле
+ DoMessage(ITXT_THREAD_MAXPROGRESS, 0, fsz);
+ inc(pt, 10);
+ i := 0;
+ while cardinal(i) < fsz do
+ begin
+ dbei.cbSize := PInteger(pt + i)^;
+ dbei.szModule := PAnsiChar(proto);
+ dbei.timestamp := PDWORD(pt + i + $08)^;
+ dbei.flags := PDWORD(pt + i + $0C)^;
+ dbei.eventtype := PDWORD(pt + i + $10)^;
+ dbei.cbBlob := PDWORD(pt + i + $14)^;
+ dbei.pBlob := PBYTE(pt + i + dbei.cbSize);
- else Inc(Duplicates);
- inc(i,dbei.cbSize+dbei.cbBlob);
- DoMessage(ITXT_THREAD_PROGRESS,i,0);
- end;
- end
- else
- begin
- s:=TranslateWideString('Can''t determine destination contact');
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
- end;
+ if not IsDuplicateEvent(DContact.hContact, dbei) then
+ if CallService(MS_DB_EVENT_ADD, wParam(DContact.hContact), lParam(@dbei)) <> 0 then
+ inc(AddedMessages)
+ else
+ begin
+ s := 'Error adding message to DB';
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ break;
+ end
+ else
+ inc(Duplicates);
+ inc(i, dbei.cbSize + integer(dbei.cbBlob));
+ DoMessage(ITXT_THREAD_PROGRESS, i, 0);
+ end;
+ end
+ else
+ begin
+ s := TranslateWideString('Can''t determine destination contact');
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ end;
end
- else
+ else
begin
- s:=WideFormat(TranslateWideString('Its not %s file'),['mContact']);
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
+ s := WideFormat(TranslateWideString('Its not %s file'), ['mContact']);
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
end
- else //file len
+ else // file len
end;
-{$endif}
+{$ENDIF}
diff --git a/plugins/ImportTXT/BqhfIP.inc b/plugins/ImportTXT/BqhfIP.inc
index 236a37de0b..26f8737b7f 100644
--- a/plugins/ImportTXT/BqhfIP.inc
+++ b/plugins/ImportTXT/BqhfIP.inc
@@ -1,131 +1,146 @@
-{$ifdef BIN_IMPORT_}
+{$IFDEF BIN_IMPORT_}
+
var
- qhfver:byte;
- szMsgHd:word;
- UIDstr:UTF8String;
- UIDLen,NickLen:word;
- NickStr:UTF8String;
+ qhfver: byte;
+ szMsgHd: word;
+ UIDstr: UTF8String;
+ UIDLen, NickLen: word;
+ NickStr: UTF8String;
-function DecodeQHFMsg(ver:byte; adr:integer; cSize:word):string;
+function DecodeQHFMsg(ver: byte; adr: integer; cSize: word): AnsiString;
-function get1(c: char): byte;
-begin
- if ShortInt(c)>=0 then Result:=Byte(c)
- else Result := Byte(c)+256;
-end;
+ function get1(c: AnsiChar): byte;
+ begin
+ if ShortInt(c) >= 0 then
+ Result := byte(c)
+ else
+ Result := byte(c) + 256;
+ end;
-function get2(b:byte): char;
-begin
- if b<128 then result:=Char(b)
- else result:=Char(b-256);
-end;
+ function get2(b: byte): AnsiChar;
+ begin
+ if b < 128 then
+ Result := AnsiChar(b)
+ else
+ Result := AnsiChar(b - 256);
+ end;
-var i:integer;
+var
+ i: integer;
begin
- SetLength(Result,cSize);
- for i:=1 to cSize do
+ SetLength(Result, cSize);
+ for i := 1 to cSize do
begin
- Result[i]:=PChar(adr+i-1)^;
- if ver<>$01 then
+ Result[i] := PAnsiChar(adr + i - 1)^;
+ if ver <> $01 then
begin
- inc(Result[i],i);
- Result[i]:=get2(255-get1(Result[i]));
+ inc(Result[i], i);
+ Result[i] := get2(255 - get1(Result[i]));
end
end;
end;
-{$else}
+{$ELSE}
+
begin
- pt:=integer(pFileText);
- if FileLen>=$2E then
- if (PChar(pt)^='Q') and (PChar(pt+1)^='H') and (PChar(pt+2)^='F') then
+ pt := uint_ptr(pFileText);
+ if FileLen >= $2E then
+ if (PAnsiChar(pt)^ = 'Q') and (PAnsiChar(pt + 1)^ = 'H') and (PAnsiChar(pt + 2)^ = 'F') then
begin
- qhfver:=PByte(pt+3)^;
- if qhfver>=$03 then szMsgHd:=$23
- else szMsgHd:=$21;
- fsz:=RLInteger(pt+$04);
- UIDLen:=RLWord(pt+$2C);
- SetLength(UIDstr,UIDLen);
- if qhfver<=2 then lstrcpynA(PChar(UIDstr),PChar(pt+$2E),UIDLen)
- else lstrcpynA(PChar(UIDstr),PChar(pt+$2E),UIDLen+1);
- NickLen:=RLWord(pt+$2E+UIDLen);
- SetLength(NickStr,NickLen);
- if qhfver<=2 then lstrcpynA(PChar(NickStr),PChar(pt+$2E+UIDLen+2),UIDLen)
- else lstrcpynA(PChar(NickStr),PChar(pt+$2E+UIDLen+2),UIDLen+1);
- inc(pt,$2E+UIDLen+2+NickLen);
- if fsz<>FileLen-($2E+UIDLen+2+NickLen) then fsz:= FileLen-($2E+UIDLen+2+NickLen);
- if (DContact.hContact=0) or (DContact.hContact=INVALID_HANDLE_VALUE) then
+ qhfver := PByte(pt + 3)^;
+ if qhfver >= $03 then
+ szMsgHd := $23
+ else
+ szMsgHd := $21;
+ fsz := RLInteger(pt + $04);
+
+ UIDLen := RLWord(pt + $2C);
+ SetLength(UIDstr, UIDLen);
+ if qhfver <= 2 then
+ lstrcpynA(PAnsiChar(UIDstr), PAnsiChar(pt + $2E), UIDLen)
+ else
+ lstrcpynA(PAnsiChar(UIDstr), PAnsiChar(pt + $2E), UIDLen + 1);
+
+ NickLen := RLWord(pt + $2E + UIDLen);
+ SetLength(NickStr, NickLen);
+ if qhfver <= 2 then
+ lstrcpynA(PAnsiChar(NickStr), PAnsiChar(pt + $2E + UIDLen + 2), UIDLen)
+ else
+ lstrcpynA(PAnsiChar(NickStr), PAnsiChar(pt + $2E + UIDLen + 2), UIDLen + 1);
+
+ inc(pt, $2E + UIDLen + 2 + NickLen);
+ if fsz <> FileLen - ($2E + UIDLen + 2 + NickLen) then
+ fsz := FileLen - ($2E + UIDLen + 2 + NickLen);
+
+ if (DContact.hContact = 0) or (DContact.hContact = INVALID_HANDLE_VALUE)
+ then
begin
- if IsMirandaUnicode then DContact.ContactUID:=UIDstr
- else
- begin
- tempstr:=UTF8ToANSI(PChar(UIDstr),tempstr,cp);
- DContact.ContactUID:=tempstr;
- FreeMem(tempstr);
- end;
- if IsMirandaUnicode then DContact.ContactNick:=NickStr
- else
- begin
- tempstr:=UTF8ToANSI(PChar(NickStr),tempstr,cp);
- DContact.ContactNick:=tempstr;
- FreeMem(tempstr);
- end;
- TryDetermContact(DContact);
+ DContact.ContactUID := UIDstr;
+ DContact.ContactNick := UTF8Decode{UTF8ToWideString}(NickStr);
+ TryDetermContact(DContact);
end;
- if (DContact.hContact=0) or (DContact.hContact=INVALID_HANDLE_VALUE) then
- if (fContact.hContact<>0) and (fContact.hContact<>INVALID_HANDLE_VALUE) then
- DContact:=fContact;
- if (DContact.hContact<>0) and (DContact.hContact<>INVALID_HANDLE_VALUE) then
- begin
- proto:=GetContactProto(DContact.hContact);
- DoMessage(ITXT_THREAD_DEST_CONTACT,DContact.hContact,0);
- DoMessage(ITXT_THREAD_START,0,0);
- DoMessage(ITXT_THREAD_MAXPROGRESS,0,fsz);
- i:=0;
- while i<fsz do
- begin
- with dbei do
- begin
- fillchar(dbei,sizeof(dbei),0);
- cbSize:=sizeof(dbei);
- szModule:=PChar(proto);
- timestamp:=RLInteger(pt+i+$12);
- timestamp:=timestamp-(PluginLink.CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,timestamp,0)-timestamp);//приводим к GMT
- if PByte(pt+i+$1A)^=$00 then flags:=0
- else flags:=DBEF_SENT;
- flags:=flags or DBEF_READ or DBEF_UTF; //в файлах лежат в utf8 и импортируются без изменений
- eventType:= EVENTTYPE_MESSAGE;
- cbBlob:=RLWord(pt+i+szMsgHd-2)+1; //размер текста сообщения с #0
- pBlob:=AllocMem(cbBlob);
- end;
- try
- Move(DecodeQHFMsg(qhfver,pt+i+szMsgHd,dbei.cbBlob-1)[1],dbei.pBlob^,dbei.cbBlob-1);
- if not IsDuplicateEvent(DContact.hContact,dbei) then
- if pluginLink^.CallService(MS_DB_EVENT_ADD, wParam(DContact.hContact), lParam(@dbei))<>0 then Inc(AddedMessages)
- else begin
- s:= 'Error adding message to DB';
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0); break; end
+ if (DContact.hContact = 0) or (DContact.hContact = INVALID_HANDLE_VALUE) then
+ if (fContact.hContact <> 0) and (fContact.hContact <> INVALID_HANDLE_VALUE) then
+ DContact := fContact;
+ if (DContact.hContact <> 0) and (DContact.hContact <> INVALID_HANDLE_VALUE) then
+ begin
+ proto := GetContactProto(DContact.hContact);
+ DoMessage(ITXT_THREAD_DEST_CONTACT, DContact.hContact, 0);
+ DoMessage(ITXT_THREAD_START, 0, 0);
+ DoMessage(ITXT_THREAD_MAXPROGRESS, 0, fsz);
+ i := 0;
+ while Cardinal(i) < fsz do
+ begin
+ fillchar(dbei, sizeof(dbei), 0);
+ dbei.cbSize := sizeof(dbei);
+ dbei.szModule := PAnsiChar(proto);
+ dbei.timestamp := RLInteger(pt + i + $12);
+ dbei.timestamp := dbei.timestamp -
+ (Cardinal(CallService(MS_DB_TIME_TIMESTAMPTOLOCAL, dbei.timestamp, 0)) - dbei.timestamp); // приводим к GMT
+ if PByte(pt + i + $1A)^ = $00 then
+ dbei.flags := DBEF_READ or DBEF_UTF
+ else
+ dbei.flags := DBEF_READ or DBEF_UTF or DBEF_SENT;
+ // в файлах лежат в utf8 и импортируются без изменений
+ dbei.eventType := EVENTTYPE_MESSAGE;
+ dbei.cbBlob := RLWord(pt + i + szMsgHd - 2) + 1;
+ // размер текста сообщения с #0
+ dbei.pBlob := AllocMem(dbei.cbBlob);
+
+ try
+ Move(DecodeQHFMsg(qhfver, pt + i + szMsgHd, dbei.cbBlob - 1)[1],
+ dbei.pBlob^, dbei.cbBlob - 1);
+ if not IsDuplicateEvent(DContact.hContact, dbei) then
+ if CallService(MS_DB_EVENT_ADD, wParam(DContact.hContact), lParam(@dbei))<>0 then
+ inc(AddedMessages)
+ else
+ begin
+ s := 'Error adding message to DB';
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ break;
+ end
- else Inc(Duplicates);
+ else
+ inc(Duplicates);
- finally
- inc(i,szMsgHd+dbei.cbBlob-1);
- FreeMem(dbei.pBlob);
+ finally
+ inc(i, szMsgHd + dbei.cbBlob - 1);
+ FreeMem(dbei.pBlob);
+ end;
+ DoMessage(ITXT_THREAD_PROGRESS, i, 0);
end;
- DoMessage(ITXT_THREAD_PROGRESS,i,0);
- end;
- end
- else
- begin
- s:=TranslateWideString('Can''t determine destination contact');
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
- end;
+ end
+ else
+ begin
+ s := TranslateWideString('Can''t determine destination contact');
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ end;
end
- else
+ else
begin
- s:=WideFormat(TranslateWideString('Its not %s file'),['QHF']);
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
+ s := WideFormat(TranslateWideString('Its not %s file'), ['QHF']);
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
end
- else //file len
+ else // file len
end;
-{$endif} \ No newline at end of file
+{$ENDIF}
diff --git a/plugins/ImportTXT/FileDlgs.pas b/plugins/ImportTXT/FileDlgs.pas
index 2257a7ab5e..59e65895b1 100644
--- a/plugins/ImportTXT/FileDlgs.pas
+++ b/plugins/ImportTXT/FileDlgs.pas
@@ -12,10 +12,11 @@ implementation
uses shlobj, activex, SysUtils, CommDlg;
function OpenDialogExecute(hDlg:hWnd; flg:cardinal; var nFO:integer; const DefExt:string):WideString; //Диалог открытия файла
-var OpenFilename:TOpenFilenameW;
- TempFilename:WideString;
- Temp1,Temp2:WideString;
- res:bool;
+var
+ OpenFilename:TOpenFilenameW;
+ TempFilename:WideString;
+ Temp1,Temp2:WideString;
+ res:bool;
begin
nFO:=0;
FillChar(OpenFileName, SizeOf(OpenFileName), 0);
@@ -37,11 +38,12 @@ begin
end;
res:=GetOpenFileNameW(OpenFileName);
if res then
- begin
+ begin
Result:=TempFilename;
nFO:=OpenFilename.nFileOffset;
- end
- else Result:='';
+ end
+ else
+ Result:='';
end;
//***Awkward - author of this procedures************
@@ -106,7 +108,7 @@ var
tpwc:PWideChar;
tws:WideString;
begin
- if SelectDirectory(PWideChar(TranslateWideString('Select folder for import...')),tpwc,hdlg,true) then
+ if SelectDirectory(TranslateW('Select folder for import...'),tpwc,hdlg,true) then
begin
result:=tpwc;
result:=result+#0;
diff --git a/plugins/ImportTXT/General.pas b/plugins/ImportTXT/General.pas
index d263dde816..3f373c618c 100644
--- a/plugins/ImportTXT/General.pas
+++ b/plugins/ImportTXT/General.pas
@@ -2,430 +2,408 @@ unit general;
interface
-uses Windows,Messages,SysUtils,IniFiles,
- m_api,
- ImportT,
- ImportTU;
+uses
+ Windows, Messages, SysUtils, IniFiles,
+ m_api,
+ ImportT,
+ ImportTU;
-var MirVers:DWORD;
- IsMirandaUnicode:boolean;
- cp:cardinal;
+var
+ cp: cardinal;
var
- AppPath:array[0..MAX_PATH] of char;
- TxtPatterns: array of RTxtPattern;
- PatternNames: array of PChar;
- PatternsCount:integer;
- Protocols:array of TDestProto;
- ProtoCount: integer;
- CheckForDuplicates:boolean;
- ShowDuplicates:boolean;
+ AppPath: array [0 .. MAX_PATH] of Char;
+ TxtPatterns: array of RTxtPattern;
+ Protocols: array of TDestProto;
+ ProtoCount: integer;
+ CheckForDuplicates: boolean;
+ ShowDuplicates: boolean;
const
- BIN_PROCEDURE_COUNT=6; //количество реализованых процедур бинарного импорта
+ BIN_PROCEDURE_COUNT = 6; // количество реализованых процедур бинарного импорта
const
- {$EXTERNALSYM PBM_SETRANGE}
- PBM_SETRANGE = WM_USER+1;
- {$EXTERNALSYM PBM_SETPOS}
- PBM_SETPOS = WM_USER+2;
+{$EXTERNALSYM PBM_SETRANGE}
+ PBM_SETRANGE = WM_USER + 1;
+{$EXTERNALSYM PBM_SETPOS}
+ PBM_SETPOS = WM_USER + 2;
const
- IMPORT_TXT_MODULE= 'ImportTXT';
- IMPORT_TXT_SERVICE= IMPORT_TXT_MODULE+'/Import';
- IMPORT_WIZ_SERVICE= IMPORT_TXT_MODULE+'/Wizard';
+ IMPORT_TXT_MODULE = 'ImportTXT';
+ IMPORT_TXT_SERVICE = IMPORT_TXT_MODULE + '/Import';
+ IMPORT_WIZ_SERVICE = IMPORT_TXT_MODULE + '/Wizard';
- //keys
- IMPORT_TXT_AS= 'AutoStart';
- IMPORT_TXT_LP= 'LastPattern';
+ // keys
+ IMPORT_TXT_AS = 'AutoStart';
+ IMPORT_TXT_LP = 'LastPattern';
-type TOnAccountListChange = procedure ();
+type
+ TOnAccountListChange = procedure();
var
- OnAccountListChange:TOnAccountListChange;
+ OnAccountListChange: TOnAccountListChange;
-function ReadPattern(FileName: string):boolean;
procedure ReadPatterns;
-procedure ExtractFilePath(fName:PChar);
-function fIsMirandaUnicode:boolean;
-function GetContactProto(hContact: THandle): String;
-function GetContactByUID(proto:string;id:string):THandle;
-function GetContactByNick(Proto:string;Nick:string):THandle;
+procedure ExtractFilePath(fName: PAnsiChar);
+function GetContactProto(hContact: THandle): AnsiString;
+function GetContactByUID(const proto: AnsiString; const id: AnsiString): THandle;
+function GetContactByNick(const proto: AnsiString; const Nick: WideString): THandle;
procedure EnumProtocols;
-function GetContactID(hContact: THandle; Proto: String = ''; Contact: boolean = false): String;
-function GetContactNick(hContact: THandle; Proto: String = ''; Contact: boolean = false): String;
-function DBReadByte (hContact:THANDLE;szModule:PChar;szSetting:PChar;default:byte =0):byte;
-function DBWriteByte (hContact:THANDLE;szModule:PChar;szSetting:PChar;val:Byte ):Integer;
-procedure SetLastPattern(lp:byte);
-function GetLastPattern:byte;
-function TimeStampToWStr(ts:dword):WideString;
-function StrToTimeStamp(STime:PChar;len:integer):dword;
-
-function RLWord(adr:integer):word;
-function RLInteger(adr:integer):integer;
+function GetContactID(hContact: THandle; proto: AnsiString = ''; Contact: boolean = false): WideString;
+function GetContactNick(hContact: THandle; proto: AnsiString = ''; Contact: boolean = false): WideString;
+function DBReadByte(hContact: THandle; szModule: PAnsiChar; szSetting: PAnsiChar; default: byte = 0): byte;
+function DBWriteByte(hContact: THandle; szModule: PAnsiChar; szSetting: PAnsiChar; val: byte): integer;
+procedure SetLastPattern(lp: byte);
+function GetLastPattern: byte;
+function TimeStampToWStr(ts: DWORD): WideString;
+function StrToTimeStamp(STime: PAnsiChar; len: integer): DWORD;
+
+function RLWord(adr: integer): word;
+function RLInteger(adr: integer): integer;
implementation
-
-procedure ExtractFilePath(fName:PChar);
-var p:PChar;
+procedure ExtractFilePath(fName: PAnsiChar);
+var
+ p: PAnsiChar;
begin
- p:=fName;
- if p<>nil then
- begin
- while p^<>#0 do inc(p);
- while p^<>'\' do dec(p);
+ p := fName;
+ if p <> nil then
+ begin
+ while p^ <> #0 do
+ inc(p);
+ while p^ <> '\' do
+ dec(p);
inc(p);
- p^:=#0;
- end;
+ p^ := #0;
+ end;
end;
-function ReadPattern(FileName: string):boolean;
-var TI: TIniFile;
- h:integer;
- Err:boolean;
- tempstr:string;
+function ReadPattern(const FileName: String): boolean;
+var
+ TI: TIniFile;
+ tempstr: String;
+ pattern:pRTxtPattern;
begin
- err:=false;
- TI:=TIniFile.Create(FileName);
- try
- h:=High(TxtPatterns);
- if not TI.SectionExists('General') then begin result:=true; exit; end;
- //if "General" exists
- if TI.ValueExists('General','Name') then TxtPatterns[h].Name:=TI.ReadString('General','Name','')
- else err:=true;
- if TI.ValueExists('General','Type') then TxtPatterns[h].IType:=TI.ReadInteger('General','Type',1)
- else err:=true;
- case TxtPatterns[h].IType of
- 1:
- begin
- if TI.ValueExists('General','Charset') then
- begin
- tempstr:=TI.ReadString('General','Charset','UTF8');
- if tempstr='ANSI' then TxtPatterns[h].Charset:=inANSI
- else
- if tempstr='UTF8' then TxtPatterns[h].Charset:=inUTF8
- else
- if tempstr='UCS2' then TxtPatterns[h].Charset:=inUCS2
- else err:=true;
- end
- else err:=true;
- if TxtPatterns[h].Charset=inANSI then
- begin
- TxtPatterns[h].Codepage:= TI.ReadInteger('General','Codepage',0);
- if not IsValidCodePage(TxtPatterns[h].Codepage) then TxtPatterns[h].Codepage:=0;
- end;
- TxtPatterns[h].UseHeader:=TI.ReadInteger('General','UseHeader',0);
- TxtPatterns[h].UsePreMsg:=TI.ReadBool('General','UsePreMsg',false);
- // Read message section
- if TI.SectionExists('Message') then
- begin
- if TI.ValueExists('Message','Pattern') then TxtPatterns[h].Msg.Pattern:=TI.ReadString('Message','Pattern','')
- else err:=true;
- TxtPatterns[h].Msg.Incoming:=TI.ReadString('Message','In','');
- TxtPatterns[h].Msg.Outgoing:=TI.ReadString('Message','Out','');
- if TI.ValueExists('Message','Direction') then TxtPatterns[h].Msg.Direction:=TI.ReadInteger('Message','Direction',0)
- else err:=true;
- if TI.ValueExists('Message','Day') then TxtPatterns[h].Msg.Day:=TI.ReadInteger('Message','Day',0)
- else err:=true;
- if TI.ValueExists('Message','Month') then TxtPatterns[h].Msg.Month:=TI.ReadInteger('Message','Month',0)
- else err:=true;
- if TI.ValueExists('Message','Year') then TxtPatterns[h].Msg.Year:=TI.ReadInteger('Message','Year',0)
- else err:=true;
- if TI.ValueExists('Message','Hours') then TxtPatterns[h].Msg.Hours:=TI.ReadInteger('Message','Hours',0)
- else err:=true;
- if TI.ValueExists('Message','Minutes') then TxtPatterns[h].Msg.Minutes:=TI.ReadInteger('Message','Minutes',0)
- else err:=true;
- TxtPatterns[h].Msg.Seconds:=TI.ReadInteger('Message','Seconds',0)
- end
- else err:=true;
- // if need read header section
- if (TxtPatterns[h].UseHeader>0) then
- if TI.SectionExists('Header') then
+ TI := TIniFile.Create(FileName);
+ try
+ if not TI.SectionExists('General') then
+ exit;
+
+ pattern:=@TxtPatterns[High(TxtPatterns)];
+ // if "General" exists
+ if TI.ValueExists('General', 'Name') then
+ pattern^.Name := TI.ReadString('General', 'Name', '')
+ else
+ exit;
+ if TI.ValueExists('General', 'Type') then
+ pattern^.IType := TI.ReadInteger('General', 'Type', 1)
+ else
+ exit;
+ case pattern^.IType of
+ 1:
begin
- if TI.ValueExists('Header','Pattern') then TxtPatterns[h].Header.Pattern:=TI.ReadString('Header','Pattern','')
- else err:=true;
- if (not TI.ValueExists('Header','In')) and ((TxtPatterns[h].UseHeader and 1)=1) then err:=true;
- TxtPatterns[h].Header.Incoming:=TI.ReadInteger('Header','In',0);
- TxtPatterns[h].Header.Outgoing:=TI.ReadInteger('Header','Out',0);
- TxtPatterns[h].Header.InNick:=TI.ReadInteger('Header','InNick',0);
- TxtPatterns[h].Header.OutNick:=TI.ReadInteger('Header','OutNick',0);
- TxtPatterns[h].Header.InUID:=TI.ReadInteger('Header','InUID',0);
- TxtPatterns[h].Header.OutUID:=TI.ReadInteger('Header','OutUID',0);
- if ((TxtPatterns[h].UseHeader and 2)=2) then
- if (TxtPatterns[h].Header.InNick=0) and (TxtPatterns[h].Header.InUID=0) then err:=true;
- end
- else err:=true;
- // if nead read PreMessage section
- if TxtPatterns[h].UsePreMsg then
- if TI.SectionExists('PreMessage') then
- begin
- TxtPatterns[h].PreMsg.PreRN:=TI.ReadInteger('PreMessage','PreRN',-1);
- TxtPatterns[h].PreMsg.AfterRN:=TI.ReadInteger('PreMessage','AfterRN',-1);
- TxtPatterns[h].PreMsg.PreSP:=TI.ReadInteger('PreMessage','PreSP',0);
- TxtPatterns[h].PreMsg.AfterSP:=TI.ReadInteger('PreMessage','AfterSP',0);
- end
- else err:=true;
- end; //1
- 2:
- begin
- TxtPatterns[h].BinProc:= TI.ReadInteger('General','BinProcedure',0);
- if (TxtPatterns[h].BinProc>BIN_PROCEDURE_COUNT) then err:=true;
- end;
- end; //case
- TxtPatterns[h].DefExtension:=TI.ReadString('General','DefaultExtension','txt');
- TxtPatterns[h].UseFileName:=TI.ReadBool('General','UseFileName',false);
- // if nead read FileName section
- if TxtPatterns[h].UseFileName then
- if TI.SectionExists('FileName') then
- begin
- if TI.ValueExists('FileName','Pattern') then TxtPatterns[h].FName.Pattern:=TI.ReadString('FileName','Pattern','')
- else err:=true;
- TxtPatterns[h].FName.InNick:=TI.ReadInteger('FileName','InNick',0);
- TxtPatterns[h].FName.InUID:=TI.ReadInteger('FileName','InUID',0);
- if (TxtPatterns[h].FName.InNick=0) and (TxtPatterns[h].FName.InUID=0) then err:=true;
- TxtPatterns[h].FName.OutNick:=TI.ReadInteger('FileName','OutNick',0);
- TxtPatterns[h].FName.OutUID:=TI.ReadInteger('FileName','OutUID',0);
- end
- else err:=true;
- finally
- TI.Free;
- end;
- Result:=err;
+ if TI.ValueExists('General', 'Charset') then
+ begin
+ tempstr := TI.ReadString('General', 'Charset', 'UTF8');
+ if tempstr = 'ANSI' then
+ pattern^.Charset := inANSI
+ else if tempstr = 'UTF8' then
+ pattern^.Charset := inUTF8
+ else if tempstr = 'UCS2' then
+ pattern^.Charset := inUCS2
+ else
+ exit;
+ end
+ else
+ exit;
+ if pattern^.Charset = inANSI then
+ begin
+ pattern^.Codepage := TI.ReadInteger('General', 'Codepage', 0);
+ if not IsValidCodePage(pattern^.Codepage) then
+ pattern^.Codepage := 0;
+ end;
+ pattern^.UseHeader := TI.ReadInteger('General', 'UseHeader', 0);
+ pattern^.UsePreMsg := TI.ReadBool('General', 'UsePreMsg', false);
+ // Read message section
+ if TI.SectionExists('Message') then
+ begin
+ if TI.ValueExists('Message', 'Pattern') then
+ pattern^.Msg.Pattern := TI.ReadString('Message', 'Pattern', '')
+ else
+ exit;
+ pattern^.Msg.Incoming := TI.ReadString('Message', 'In', '');
+ pattern^.Msg.Outgoing := TI.ReadString('Message', 'Out', '');
+ if TI.ValueExists('Message', 'Direction') then
+ pattern^.Msg.Direction := TI.ReadInteger('Message', 'Direction', 0)
+ else
+ exit;
+ if TI.ValueExists('Message', 'Day') then
+ pattern^.Msg.Day := TI.ReadInteger('Message', 'Day', 0)
+ else
+ exit;
+ if TI.ValueExists('Message', 'Month') then
+ pattern^.Msg.Month := TI.ReadInteger('Message', 'Month', 0)
+ else
+ exit;
+ if TI.ValueExists('Message', 'Year') then
+ pattern^.Msg.Year := TI.ReadInteger('Message', 'Year', 0)
+ else
+ exit;
+ if TI.ValueExists('Message', 'Hours') then
+ pattern^.Msg.Hours := TI.ReadInteger('Message', 'Hours', 0)
+ else
+ exit;
+ if TI.ValueExists('Message', 'Minutes') then
+ pattern^.Msg.Minutes := TI.ReadInteger('Message', 'Minutes', 0)
+ else
+ exit;
+ pattern^.Msg.Seconds := TI.ReadInteger('Message', 'Seconds', 0)
+ end
+ else
+ exit;
+ // if need read header section
+ if (pattern^.UseHeader > 0) then
+ if TI.SectionExists('Header') then
+ begin
+ if TI.ValueExists('Header', 'Pattern') then
+ pattern^.Header.Pattern := TI.ReadString('Header', 'Pattern', '')
+ else
+ exit;
+ if (not TI.ValueExists('Header', 'In')) and
+ ((pattern^.UseHeader and 1) = 1) then
+ exit;
+ pattern^.Header.Incoming := TI.ReadInteger('Header', 'In', 0);
+ pattern^.Header.Outgoing := TI.ReadInteger('Header', 'Out', 0);
+ pattern^.Header.InNick := TI.ReadInteger('Header', 'InNick', 0);
+ pattern^.Header.OutNick := TI.ReadInteger('Header', 'OutNick', 0);
+ pattern^.Header.InUID := TI.ReadInteger('Header', 'InUID', 0);
+ pattern^.Header.OutUID := TI.ReadInteger('Header', 'OutUID', 0);
+ if ((pattern^.UseHeader and 2) = 2) then
+ if (pattern^.Header.InNick = 0) and
+ (pattern^.Header.InUID = 0) then
+ exit;
+ end
+ else
+ exit;
+ // if nead read PreMessage section
+ if pattern^.UsePreMsg then
+ if TI.SectionExists('PreMessage') then
+ begin
+ pattern^.PreMsg.PreRN := TI.ReadInteger('PreMessage', 'PreRN', -1);
+ pattern^.PreMsg.AfterRN := TI.ReadInteger('PreMessage', 'AfterRN', -1);
+ pattern^.PreMsg.PreSP := TI.ReadInteger('PreMessage', 'PreSP', 0);
+ pattern^.PreMsg.AfterSP := TI.ReadInteger('PreMessage', 'AfterSP', 0);
+ end
+ else
+ exit;
+ end; // 1
+ 2:
+ begin
+ pattern^.BinProc := TI.ReadInteger('General', 'BinProcedure', 0);
+ if (pattern^.BinProc > BIN_PROCEDURE_COUNT) then
+ exit;
+ end;
+ end; // case
+ pattern^.DefExtension := TI.ReadString('General', 'DefaultExtension', 'txt');
+ pattern^.UseFileName := TI.ReadBool('General', 'UseFileName', false);
+ // if nead read FileName section
+ if pattern^.UseFileName then
+ if TI.SectionExists('FileName') then
+ begin
+ if TI.ValueExists('FileName', 'Pattern') then
+ pattern^.fName.Pattern := TI.ReadString('FileName', 'Pattern', '')
+ else
+ exit;
+ pattern^.fName.InNick := TI.ReadInteger('FileName', 'InNick', 0);
+ pattern^.fName.InUID := TI.ReadInteger('FileName', 'InUID', 0);
+ if (pattern^.fName.InNick = 0) and (pattern^.fName.InUID = 0) then
+ exit;
+ pattern^.fName.OutNick := TI.ReadInteger('FileName', 'OutNick', 0);
+ pattern^.fName.OutUID := TI.ReadInteger('FileName', 'OutUID', 0);
+ end
+ else
+ exit;
+ finally
+ TI.Free;
+ result := true;
+ end;
+ result := false;
end;
procedure ReadPatterns;
var
SR: TSearchRec;
- FileAttrs: Integer;
- i:integer;
+ FileAttrs: integer;
+ i: integer;
begin
- FileAttrs:=faAnyFile;
- i:=0;
- if FindFirst(AppPath+'\importtxt\*.ini',FileAttrs,SR)=0 then
- begin
- repeat
- SetLength(TxtPatterns,i+1);
- SetLength(PatternNames,i+1);
- if not ReadPattern(AppPath+'\importtxt\'+SR.Name) then
- begin
- PatternNames[i]:= PChar(TxtPatterns[i].Name);
- inc(i);
- end;
- until FindNext(SR) <> 0 ;
- FindClose(SR);
- end;
- PatternsCount:=i;
+ FileAttrs := faAnyFile;
+ i := 0;
+ if FindFirst(AppPath + '\importtxt\*.ini', FileAttrs, SR) = 0 then
+ begin
+ repeat
+ SetLength(TxtPatterns, i+1);
+ if not ReadPattern(AppPath + '\importtxt\' + SR.Name) then
+ inc(i);
+ until FindNext(SR) <> 0;
+ FindClose(SR);
+ end;
+ // cut unneded
+ SetLength(TxtPatterns, i);
end;
-
-function GetContactByUID(proto:string;id:string):THandle;
+function GetContactByUID(const proto: AnsiString; const id: AnsiString): THandle;
var
- contact:THandle;
- otherproto:string;
- ci:TCONTACTINFO;
- idnum:integer;
- tempwstr:PWideChar;
- ws:WideString;
+ Contact: THandle;
+ otherproto: AnsiString;
+ ci: TCONTACTINFO;
+ idnum: integer;
+ tempwstr: PWideChar;
+ ws: WideString;
begin
- if not TryStrToInt(id,idnum) then idnum:=0;
- if IsMirandaUnicode then
- begin
- tempwstr:=UTF8ToWide(PChar(id),tempwstr);
- ws :=tempwstr;
- FreeMem(tempwstr);
- end;
- result:=INVALID_HANDLE_VALUE;
- contact:=pluginlink^.CallService(MS_DB_CONTACT_FINDFIRST, 0, 0 );
- while (contact<>0) do
+ if not TryStrToInt(id, idnum) then
+ idnum := 0;
+ tempwstr := UTF8ToWide(PAnsiChar(id), tempwstr);
+ ws := tempwstr;
+ FreeMem(tempwstr);
+ Contact := CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ while (Contact <> 0) do
begin
- otherproto:=PChar(pluginlink^.CallService(MS_PROTO_GETCONTACTBASEPROTO,contact,0));
- if otherproto=proto then
+ otherproto := PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO, Contact, 0));
+ if otherproto = proto then
begin
- ci.cbSize:=SizeOf(ci);
- ci.dwFlag:=CNF_UNIQUEID;
- if IsMirandaUnicode then ci.dwFlag:=ci.dwFlag or CNF_UNICODE;
- ci.hContact:=contact;
- ci.szProto:=PChar(otherproto);
- if pluginlink^.CallService(MS_CONTACT_GETCONTACTINFO,0,integer(@ci))=0 then
+ ci.cbSize := SizeOf(ci);
+ ci.dwFlag := CNF_UNIQUEID or CNF_UNICODE;
+ ci.hContact := Contact;
+ ci.szProto := PAnsiChar(otherproto);
+ if CallService(MS_CONTACT_GETCONTACTINFO, 0, lparam(@ci)) = 0 then
begin
- case ( ci._type ) of
- CNFT_BYTE: if ci.retval.bVal = idnum then
- begin
- result:=contact;
- break;
- end;
- CNFT_WORD: if ci.retval.wVal = idnum then
- begin
- result:=contact;
- break;
- end;
- CNFT_DWORD: if ci.retval.dVal = DWORD(idnum) then
- begin
- result:=contact;
- break;
- end;
- CNFT_ASCIIZ:
- if IsMirandaUnicode then
- if ws=ci.retval.szVal.w then
- begin
- result:=contact;
- break;
- end else
- else
- if id=ci.retval.szVal.a then
- begin
- result:=contact;
- break;
- end;
- end; //case
- end; //if
- end; //if
- contact:= Pluginlink^.CallService(MS_DB_CONTACT_FINDNEXT,contact,0);
- end; //while
+ case (ci._type) of
+ CNFT_BYTE: if ci.retval.bVal = idnum then break;
+ CNFT_WORD: if ci.retval.wVal = idnum then break;
+ CNFT_DWORD: if ci.retval.dVal = DWORD(idnum) then break;
+ CNFT_ASCIIZ: if ws = ci.retval.szVal.w then break;
+ end; // case
+ end; // if
+ end; // if
+ Contact := CallService(MS_DB_CONTACT_FINDNEXT, Contact, 0);
+ end; // while
+ if Contact=0 then
+ result := INVALID_HANDLE_VALUE
+ else
+ result := Contact;
end;
-function GetContactByNick(Proto:string;Nick:string):THandle;
+function GetContactByNick(const proto: AnsiString; const Nick: WideString): THandle;
var
- contact:THandle;
- otherproto:string;
- ci:TCONTACTINFO;
- tempwstr:PWideChar;
- ws:WideString;
+ Contact: THandle;
+ otherproto: AnsiString;
+ ci: TCONTACTINFO;
begin
- if IsMirandaUnicode then
- begin
- tempwstr:=UTF8ToWide(PChar(Nick),tempwstr);
- ws :=tempwstr;
- FreeMem(tempwstr);
- end;
- result:=INVALID_HANDLE_VALUE;
- contact:=pluginlink^.CallService(MS_DB_CONTACT_FINDFIRST, 0, 0 );
- while (contact<>0) do
+ result := INVALID_HANDLE_VALUE;
+ Contact := CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ while (Contact <> 0) do
begin
- otherproto:=PChar(pluginlink^.CallService(MS_PROTO_GETCONTACTBASEPROTO,contact,0));
- if otherproto=proto then
+ otherproto := PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO, Contact, 0));
+ if otherproto = proto then
begin
- ci.cbSize:=SizeOf(ci);
- ci.dwFlag:=CNF_NICK;
- if IsMirandaUnicode then ci.dwFlag:=ci.dwFlag or CNF_UNICODE;
- ci.hContact:=contact;
- ci.szProto:=PChar(otherproto);
- if pluginlink^.CallService(MS_CONTACT_GETCONTACTINFO,0,integer(@ci))=0 then
+ ci.cbSize := SizeOf(ci);
+ ci.dwFlag := CNF_NICK;
+ ci.dwFlag := ci.dwFlag or CNF_UNICODE;
+ ci.hContact := Contact;
+ ci.szProto := PAnsiChar(otherproto);
+ if CallService(MS_CONTACT_GETCONTACTINFO, 0, lparam(@ci)) = 0 then
begin
- if IsMirandaUnicode then
- begin
- if ws=ci.retval.szVal.w then
- begin
- result:=contact;
- break;
- end;
- end
- else
- begin
- if Nick=ci.retval.szVal.a then
- begin
- result:=contact;
- break;
- end;
- end;
- end; //if
- end; //if
- contact:= Pluginlink^.CallService(MS_DB_CONTACT_FINDNEXT,contact,0);
- end; //while
+ if Nick = ci.retval.szVal.w then
+ begin
+ result := Contact;
+ break;
+ end;
+ end; // if
+ end; // if
+ Contact := CallService(MS_DB_CONTACT_FINDNEXT, Contact, 0);
+ end; // while
end;
procedure EnumProtocols;
-var i,iProtoCount:integer;
- ppAccounts:^PPROTOACCOUNT;
- temps:string;
+var
+ i, iProtoCount: integer;
+ ppAccounts: ^PPROTOACCOUNT;
+ temps: WideString;
begin
- ProtoCount:=0;
- SetLength(Protocols,30);
- if MirVers> $080000 then pluginLink^.CallService(MS_PROTO_ENUMACCOUNTS,int(@iProtoCount),int(@ppAccounts))
- else pluginLink^.CallService(MS_PROTO_ENUMPROTOCOLS,int(@iProtoCount),int(@ppAccounts));
- for i:=1 to iProtoCount do
- begin
- if (ppAccounts^^._type=PROTOTYPE_PROTOCOL) then
- begin
- temps:=GetContactID(0,ppAccounts^^.szModuleName,false);
- if temps<>'' then
- begin
- protocols[ProtoCount].ProtoName:=ppAccounts^^.szModuleName;
- protocols[ProtoCount].ProtoUID:=temps;
- protocols[ProtoCount].ProtoNick:=GetContactNick(0,ppAccounts^^.szModuleName,false);
+ ProtoCount := 0;
+ SetLength(Protocols, 30);
+ CallService(MS_PROTO_ENUMACCOUNTS, int(@iProtoCount), int(@ppAccounts));
+ for i := 1 to iProtoCount do
+ begin
+ if (ppAccounts^^._type = PROTOTYPE_PROTOCOL) then
+ begin
+ temps := GetContactID(0, ppAccounts^^.szModuleName, false);
+ if temps <> '' then
+ begin
+ Protocols[ProtoCount].ProtoName := ppAccounts^^.szModuleName;
+ Protocols[ProtoCount].ProtoUID := temps;
+ Protocols[ProtoCount].ProtoNick := GetContactNick(0, ppAccounts^^.szModuleName, false);
inc(ProtoCount);
- end;
- end;
+ end;
+ end;
inc(ppAccounts);
- end;
- SetLength(Protocols,ProtoCount);
-end;
-
-function fIsMirandaUnicode:boolean;
-var ver:ShortString;
-begin
- Result:=true;
- SetLength(ver,255);
- if PluginLink.CallService(MS_SYSTEM_GETVERSIONTEXT,wParam(255),lParam(@ver[1]))=0 then
- Result:=Pos('Unicode',ver)>0;
+ end;
+ SetLength(Protocols, ProtoCount);
end;
-function GetContactProto(hContact: THandle): String;
+function GetContactProto(hContact: THandle): AnsiString;
begin
- Result := PChar(PluginLink.CallService(MS_PROTO_GETCONTACTBASEPROTO,hContact,0));
+ result := PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0));
end;
-function DBFreeVariant(dbv:PDBVARIANT):integer;
+function DBFreeVariant(dbv: PDBVARIANT): integer;
begin
- Result:=PluginLink^.CallService(MS_DB_CONTACT_FREEVARIANT,0,lParam(dbv));
+ result := CallService(MS_DB_CONTACT_FREEVARIANT, 0, lParam(dbv));
end;
-function GetContactID(hContact: THandle; Proto: String = ''; Contact: boolean = false): String;
+function GetContactID(hContact: THandle; proto: AnsiString = '';
+ Contact: boolean = false): WideString;
var
- uid: PChar;
+ uid: PAnsiChar;
dbv: TDBVARIANT;
cgs: TDBCONTACTGETSETTING;
- tempstr:PChar;
+ tempstr: PWideChar;
begin
- Result := '';
- if not ((hContact = 0) and Contact) then begin
- if Proto = '' then Proto := GetContactProto(hContact);
- uid := PChar(CallProtoService(PChar(Proto),PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0));
- if (Cardinal(uid) <> CALLSERVICE_NOTFOUND) and (uid <> nil) then begin
- cgs.szModule := PChar(Proto);
+ result := '';
+ if not((hContact = 0) and Contact) then
+ begin
+ if proto = '' then
+ proto := GetContactProto(hContact);
+ uid := PAnsiChar(CallProtoService(PAnsiChar(proto), PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0));
+ if (uint_ptr(uid) <> CALLSERVICE_NOTFOUND) and (uid <> nil) then
+ begin
+ cgs.szModule := PAnsiChar(proto);
cgs.szSetting := uid;
cgs.pValue := @dbv;
- if PluginLink^.CallService(MS_DB_CONTACT_GETSETTING,hContact,LPARAM(@cgs)) = 0 then begin
+ if CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) = 0 then
+ begin
case dbv._type of
DBVT_BYTE:
- Result := intToStr(dbv.bVal);
+ result := intToStr(dbv.bVal);
DBVT_WORD:
- Result := intToStr(dbv.wVal);
+ result := intToStr(dbv.wVal);
DBVT_DWORD:
- Result := intToStr(dbv.dVal);
+ result := intToStr(dbv.dVal);
DBVT_ASCIIZ:
- if IsMirandaUnicode then
- begin
- tempstr:=ANSIToUTF8(dbv.szVal.a,tempstr,cp);
- Result :=tempstr;
- FreeMem(tempstr);
- end else Result := dbv.szVal.a;
- DBVT_UTF8:
- if IsMirandaUnicode then Result :=dbv.szVal.a
- else
- begin
- tempstr:=UTF8ToANSI(dbv.szVal.a,tempstr,cp);
- Result :=tempstr;
+ begin
+ tempstr := ANSIToWide(dbv.szVal.a, tempstr, cp);
+ result := tempstr;
FreeMem(tempstr);
- end;
- DBVT_WCHAR:
+ end;
+ DBVT_UTF8:
begin
- if IsMirandaUnicode then tempstr:=WideToUTF8(dbv.szVal.w,tempstr)
- else tempstr:=WideToAnsi(dbv.szVal.w,tempstr,cp);
- Result:=tempstr;
- FreeMem(tempstr);
+ tempstr := UTF8ToWide(dbv.szVal.a, tempstr);
+ result := tempstr;
+ FreeMem(tempstr);
end;
+ DBVT_WCHAR:
+ result := dbv.szVal.w;
end;
// free variant
DBFreeVariant(@dbv);
@@ -434,129 +412,131 @@ begin
end;
end;
-function GetContactNick(hContact: THandle; Proto: String = ''; Contact: boolean = false): String;
+function GetContactNick(hContact: THandle; proto: AnsiString = '';
+ Contact: boolean = false): WideString;
var
dbv: TDBVARIANT;
cgs: TDBCONTACTGETSETTING;
- tempstr:PChar;
+ tempstr: PWideChar;
begin
- Result := '';
- if not ((hContact = 0) and Contact) then begin
- if Proto = '' then Proto := GetContactProto(hContact);
- cgs.szModule := PChar(Proto);
- cgs.szSetting := 'Nick';
- cgs.pValue := @dbv;
- if PluginLink^.CallService(MS_DB_CONTACT_GETSETTING,hContact,LPARAM(@cgs)) = 0 then begin
- case dbv._type of
- DBVT_BYTE:
- Result := intToStr(dbv.bVal);
- DBVT_WORD:
- Result := intToStr(dbv.wVal);
- DBVT_DWORD:
- Result := intToStr(dbv.dVal);
- DBVT_ASCIIZ:
- if IsMirandaUnicode then
- begin
- tempstr:=ANSIToUTF8(dbv.szVal.a,tempstr,cp);
- Result :=tempstr;
- FreeMem(tempstr);
- end else Result := dbv.szVal.a;
- DBVT_UTF8:
- if IsMirandaUnicode then Result :=dbv.szVal.a
- else
- begin
- tempstr:=UTF8ToANSI(dbv.szVal.a,tempstr,cp);
- Result :=tempstr;
- FreeMem(tempstr);
- end;
- DBVT_WCHAR:
- begin
- if IsMirandaUnicode then tempstr:=WideToUTF8(dbv.szVal.w,tempstr)
- else tempstr:=WideToAnsi(dbv.szVal.w,tempstr,cp);
- Result:=tempstr;
- FreeMem(tempstr);
- end;
- end;
- // free variant
- DBFreeVariant(@dbv);
+ result := '';
+ if not((hContact = 0) and Contact) then
+ begin
+ if proto = '' then
+ proto := GetContactProto(hContact);
+ cgs.szModule := PAnsiChar(proto);
+ cgs.szSetting := 'Nick';
+ cgs.pValue := @dbv;
+ if CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) = 0 then
+ begin
+ case dbv._type of
+ DBVT_BYTE:
+ result := intToStr(dbv.bVal);
+ DBVT_WORD:
+ result := intToStr(dbv.wVal);
+ DBVT_DWORD:
+ result := intToStr(dbv.dVal);
+ DBVT_ASCIIZ:
+ begin
+ tempstr := ANSIToWide(dbv.szVal.a, tempstr, cp);
+ result := tempstr;
+ FreeMem(tempstr);
+ end;
+ DBVT_UTF8:
+ begin
+ tempstr := UTF8ToWide(dbv.szVal.a, tempstr);
+ result := tempstr;
+ FreeMem(tempstr);
+ end;
+ DBVT_WCHAR:
+ result := dbv.szVal.w;
end;
+ // free variant
+ DBFreeVariant(@dbv);
+ end;
end;
end;
-function DBReadByte(hContact:THANDLE;szModule:PChar;szSetting:PChar;default:byte=0):byte;
+function DBReadByte(hContact: THandle; szModule: PAnsiChar;
+ szSetting: PAnsiChar; default: byte = 0): byte;
var
- dbv:TDBVARIANT;
- cgs:TDBCONTACTGETSETTING;
+ dbv: TDBVARIANT;
+ cgs: TDBCONTACTGETSETTING;
begin
- cgs.szModule :=szModule;
- cgs.szSetting:=szSetting;
- cgs.pValue :=@dbv;
- If PluginLink^.CallService(MS_DB_CONTACT_GETSETTING,hContact,lParam(@cgs))<>0 then
- Result:=default
+ cgs.szModule := szModule;
+ cgs.szSetting := szSetting;
+ cgs.pValue := @dbv;
+ If CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) <> 0 then
+ result := default
else
- Result:=dbv.bVal;
+ result := dbv.bVal;
end;
-function DBWriteByte(hContact:THANDLE;szModule:PChar;szSetting:PChar;val:Byte):Integer;
+function DBWriteByte(hContact: THandle; szModule: PAnsiChar; szSetting: PAnsiChar; val: byte): integer;
var
- cws:TDBCONTACTWRITESETTING;
+ cws: TDBCONTACTWRITESETTING;
begin
- cws.szModule :=szModule;
- cws.szSetting :=szSetting;
- cws.value._type:=DBVT_BYTE;
- cws.value.bVal :=Val;
- Result:=PluginLink^.CallService(MS_DB_CONTACT_WRITESETTING,hContact,lParam(@cws));
+ cws.szModule := szModule;
+ cws.szSetting := szSetting;
+ cws.value._type := DBVT_BYTE;
+ cws.value.bVal := val;
+ result := CallService(MS_DB_CONTACT_WRITESETTING, hContact, lParam(@cws));
end;
-procedure SetLastPattern(lp:byte);
+procedure SetLastPattern(lp: byte);
begin
- DBWriteByte(0,IMPORT_TXT_MODULE,IMPORT_TXT_LP,lp);
+ DBWriteByte(0, IMPORT_TXT_MODULE, IMPORT_TXT_LP, lp);
end;
-function GetLastPattern:byte;
+function GetLastPattern: byte;
begin
- result:=DBReadByte(0,IMPORT_TXT_MODULE,IMPORT_TXT_LP,0);
- if result>=PatternsCount then result:=0;
+ result := DBReadByte(0, IMPORT_TXT_MODULE, IMPORT_TXT_LP, 0);
+ if result >= Length(TxtPatterns) then
+ result := 0;
end;
-function TimeStampToWStr(ts:dword):WideString;
-var dbtts:TDBTIMETOSTRING;
- s:WideString;
+function TimeStampToWStr(ts: DWORD): WideString;
+var
+ dbtts: TDBTIMETOSTRING;
+ s: WideString;
begin
- SetLength(s,20);
- dbtts.szFormat.w:='d s';
- dbtts.szDest.w:=PWideChar(s);
- dbtts.cbDest:=20;
- pluginlink^.CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT,ts,Int(@dbtts));
- result:=s;
+ SetLength(s, 20);
+ dbtts.szFormat.w := 'd s';
+ dbtts.szDest.w := PWideChar(s);
+ dbtts.cbDest := 20;
+ CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, ts, int(@dbtts));
+ result := s;
end;
-function StrToTimeStamp(STime:PChar;len:integer):dword;
-var hour, min, sec, day, month, year: integer;
+function StrToTimeStamp(STime: PAnsiChar; len: integer): DWORD;
+var
+ hour, min, sec, Day, Month, Year: integer;
begin
- sec:=0;
- day:=(ord(stime[0])-$30)*10+(ord(stime[1])-$30);
- month:=(ord(stime[3])-$30)*10+(ord(stime[4])-$30);
- year:=(ord(stime[6])-$30)*1000+(ord(stime[7])-$30)*100+(ord(stime[8])-$30)*10+(ord(stime[9])-$30);
- hour:=(ord(stime[11])-$30)*10+(ord(stime[12])-$30);
- min:=(ord(stime[14])-$30)*10+(ord(stime[15])-$30);
- if len>15 then sec:=(ord(stime[17])-$30)*10+(ord(stime[18])-$30);
- result:=Timestamp(year,month,day,hour,min,sec);
+ sec := 0;
+ Day := (ord(STime[0]) - $30) * 10 + (ord(STime[1]) - $30);
+ Month := (ord(STime[3]) - $30) * 10 + (ord(STime[4]) - $30);
+ Year := (ord(STime[6]) - $30) * 1000 + (ord(STime[7]) - $30) * 100 +
+ (ord(STime[8]) - $30) * 10 + (ord(STime[9]) - $30);
+ hour := (ord(STime[11]) - $30) * 10 + (ord(STime[12]) - $30);
+ min := (ord(STime[14]) - $30) * 10 + (ord(STime[15]) - $30);
+ if len > 15 then
+ sec := (ord(STime[17]) - $30) * 10 + (ord(STime[18]) - $30);
+ result := Timestamp(Year, Month, Day, hour, min, sec);
end;
-function RLWord(adr:integer):word;
+function RLWord(adr: integer): word;
begin
- Result:=PByte(adr+1)^ + (PByte(adr)^ *$100);
+ result := PByte(adr + 1)^ + (PByte(adr)^ * $100);
end;
-function RLInteger(adr:integer):integer;
+function RLInteger(adr: integer): integer;
begin
- Result:=PByte(adr+3)^ + (PByte(adr+2)^*$100) +
- (PByte(adr+1)^ * $10000) + (PByte(adr)^ *$1000000);
+ result := PByte(adr + 3)^ + (PByte(adr + 2)^ * $100) +
+ (PByte(adr + 1)^ * $10000) + (PByte(adr)^ * $1000000);
end;
begin
- GetModuleFileName(hInstance,@AppPath[0],MAX_PATH);
- ExtractFilePath(AppPath);
+ GetModuleFileName(hInstance, @AppPath[0], MAX_PATH);
+ ExtractFilePath(@AppPath);
ReadPatterns;
end.
diff --git a/plugins/ImportTXT/ImpDlgRes.inc b/plugins/ImportTXT/ImpDlgRes.inc
index b176adb9a5..b5ee3604ef 100644
--- a/plugins/ImportTXT/ImpDlgRes.inc
+++ b/plugins/ImportTXT/ImpDlgRes.inc
@@ -1,12 +1,13 @@
const
- IDD_IMPDIALOG = 101;
- IDSTART = 1001;
- IDC_FILENAME = 1002;
- IDC_BRWSBTN = 1003;
- IDC_TYPECOMBO = 1004;
- IDC_STATUSLIST = 1005;
- IDC_PROGRESS = 1006;
- IDC_CHKDUP = 1007;
- IDC_SHOWDUP = 1008;
+ IDD_IMPDIALOG = 101;
+
+ IDSTART = 1001;
+ IDC_FILENAME = 1002;
+ IDC_BRWSBTN = 1003;
+ IDC_TYPECOMBO = 1004;
+ IDC_STATUSLIST = 1005;
+ IDC_PROGRESS = 1006;
+ IDC_CHKDUP = 1007;
+ IDC_SHOWDUP = 1008;
- IDI_DEFAULT = 110; \ No newline at end of file
+ IDI_DEFAULT = 110;
diff --git a/plugins/ImportTXT/ImpWizRes.inc b/plugins/ImportTXT/ImpWizRes.inc
index a60bba6a54..3770583df9 100644
--- a/plugins/ImportTXT/ImpWizRes.inc
+++ b/plugins/ImportTXT/ImpWizRes.inc
@@ -1,21 +1,23 @@
const
- IDC_BACK = 3;
- IDD_IMPWIZARD = 102;
- IDD_IMPWIZARDINTRO = 103;
- IDD_IMPTYPE = 104;
- IDD_IMPFILES = 105;
- IDD_IMPDEST = 106;
- IDD_PROGRESS = 107;
- IDC_FILE = 1001;
- IDC_LIST = 1002;
- IDC_PATH = 1003;
- IDC_PROGRESS = 1004;
- IDC_DIR = 1005;
- IDC_STATUS = 1006;
- IDC_COMBO1 = 1007;
- IDC_STATIC3 = 1008;
- IDC_STATIC2 = 1009;
- IDC_STATIC1 = 1010;
- IDC_STATIC = 1011;
- IDC_CHKDUPW = 1012;
- IDC_SHOWDUPW = 1013;
+ IDC_BACK = 3;
+
+ IDD_IMPWIZARD = 102;
+ IDD_IMPWIZARDINTRO = 103;
+ IDD_IMPTYPE = 104;
+ IDD_IMPFILES = 105;
+ IDD_IMPDEST = 106;
+ IDD_PROGRESS = 107;
+
+ IDC_FILE = 1001;
+ IDC_LIST = 1002;
+ IDC_PATH = 1003;
+ IDC_PROGRESS = 1004;
+ IDC_DIR = 1005;
+ IDC_STATUS = 1006;
+ IDC_COMBO1 = 1007;
+ IDC_STATIC3 = 1008;
+ IDC_STATIC2 = 1009;
+ IDC_STATIC1 = 1010;
+ IDC_STATIC = 1011;
+ IDC_CHKDUPW = 1012;
+ IDC_SHOWDUPW = 1013;
diff --git a/plugins/ImportTXT/ImportT.pas b/plugins/ImportTXT/ImportT.pas
index 4976d2cc39..7a9b9cc935 100644
--- a/plugins/ImportTXT/ImportT.pas
+++ b/plugins/ImportTXT/ImportT.pas
@@ -1,10 +1,12 @@
unit ImportT;
interface
+uses windows;
+
type
RHeader = record
- Pattern:string;
+ Pattern:String;
Incoming:integer;
Outgoing:integer;
InNick:integer;
@@ -21,9 +23,9 @@ type
end;
RMessage = record
- Pattern:string;
- Incoming:string;
- Outgoing:string;
+ Pattern:String;
+ Incoming:String;
+ Outgoing:String;
Direction:integer;
Day:integer;
Month:integer;
@@ -34,19 +36,20 @@ type
end;
RFileName = record
- Pattern:string;
+ Pattern:String;
InNick:integer;
OutNick:integer;
InUID:integer;
OutUID:integer;
end;
+ pRTxtPattern = ^RTxtPattern;
RTxtPattern = record
- Name:string;
+ Name:String;
IType:byte; //1 -text,2- binary, 3 - ...
Charset:word;
Codepage:Cardinal;
- DefExtension:string;
+ DefExtension:String;
BinProc:word;
UseHeader:Byte;
UseFileName:ByteBool;
@@ -62,20 +65,22 @@ const
inUTF8 = 2;
inUCS2 = 3;
-type PDestProto = ^TDestProto;
- TDestProto = record
- ProtoName: string;
- ProtoUID: string;
- ProtoNick: string;
- end;
+type
+ PDestProto = ^TDestProto;
+ TDestProto = record
+ ProtoName: AnsiString;
+ ProtoUID: WideString;
+ ProtoNick: WideString;
+ end;
-type PDestContact = ^TDestContact;
- TDestContact = record
- hContact: THandle;
- ProtoName: string;
- ContactUID: string;
- ContactNick: string;
- end;
+type
+ PDestContact = ^TDestContact;
+ TDestContact = record
+ hContact: THandle;
+ ProtoName: AnsiString;
+ ContactUID: AnsiString;
+ ContactNick: WideString;
+ end;
implementation
diff --git a/plugins/ImportTXT/ImportTU.pas b/plugins/ImportTXT/ImportTU.pas
index 1ef7bdd4c3..b81a21167d 100644
--- a/plugins/ImportTXT/ImportTU.pas
+++ b/plugins/ImportTXT/ImportTU.pas
@@ -2,259 +2,267 @@ Unit ImportTU;
interface
-Uses windows, StrUtils,
- m_api;
+Uses windows, // StrUtils,
+ m_api;
type
PDayTable = ^TDayTable;
- TDayTable = array[1..12] of Word;
+ TDayTable = array [1 .. 12] of Word;
const
- MonthDays: array [Boolean] of TDayTable =
- ((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
- (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));
+ MonthDays: array [Boolean] of TDayTable = (
+ (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
+ (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));
-function Timestamp(Year,Month,Day,Hour,Min,Sec:Word; toGMT:boolean = true):LongWord;
-{function TimestampICQ(Year,Month,Day,Hour,Min,Sec:Word):LongWord;}
-function DateTimeToTimeStamp(const DateTime: TDateTime; toGMT: boolean = true): DWord;
-
-
-
-{***** Authtor of this procedures Alexey Kulakov aka Awkward*****}
-function ChangeUnicode(str:PWideChar):PWideChar;
-function UTF8Len(src:PChar):integer;
-function WideToANSI(src:PWideChar;var dst:PChar ;cp:dword=CP_ACP):PChar;
-function ANSIToWide(src:PChar ;var dst:PWideChar;cp:dword=CP_ACP):PWideChar;
-function ANSIToUTF8(src:PChar ;var dst:pChar ;cp:dword=CP_ACP):PChar;
-function UTF8toANSI(src:PChar ;var dst:PChar ;cp:dword=CP_ACP):PChar;
-function UTF8toWide(src:PChar ;var dst:PWideChar;len:cardinal=dword(-1)):PWideChar;
-function WidetoUTF8(src:PWideChar;var dst:PChar ):PChar;
-{*****}
+function Timestamp(Year, Month, Day, Hour, Min, Sec: Word; toGMT: Boolean = true): LongWord;
+{ function TimestampICQ(Year,Month,Day,Hour,Min,Sec:Word):LongWord; }
+function DateTimeToTimeStamp(const DateTime: TDateTime; toGMT: Boolean = true): DWord;
+{ ***** Authtor of this procedures Alexey Kulakov aka Awkward***** }
+function ChangeUnicode(str: PWideChar): PWideChar;
+function UTF8Len(src: PAnsiChar): integer;
+function WideToANSI(src: PWideChar; var dst: PAnsiChar; cp: DWord = CP_ACP): PAnsiChar;
+function ANSIToWide(src: PAnsiChar; var dst: PWideChar; cp: DWord = CP_ACP): PWideChar;
+function ANSIToUTF8(src: PAnsiChar; var dst: PAnsiChar; cp: DWord = CP_ACP): PAnsiChar;
+function UTF8toANSI(src: PAnsiChar; var dst: PAnsiChar; cp: DWord = CP_ACP): PAnsiChar;
+function UTF8toWide(src: PAnsiChar; var dst: PWideChar; len: cardinal = DWord(-1)): PWideChar;
+function WidetoUTF8(src: PWideChar; var dst: PAnsiChar): PAnsiChar;
+{ ***** }
implementation
uses SysUtils;
-function IsLeapYear(Year:Word):Boolean;
+function IsLeapYear(Year: Word): Boolean;
begin
- Result:=(Year mod 4=0) and ((Year mod 100<>0) or (Year mod 400=0));
+ Result := (Year mod 4 = 0) and ((Year mod 100 <> 0) or (Year mod 400 = 0));
end;
-function Timestamp(Year,Month,Day,Hour,Min,Sec:Word; toGMT: boolean = true):LongWord;
-var i:Integer;
- DayTable:PDayTable;
- DT,D:Longword;
+function Timestamp(Year, Month, Day, Hour, Min, Sec: Word; toGMT: Boolean = true): LongWord;
+var
+ i: integer;
+ DayTable: PDayTable;
+ DT, D: LongWord;
begin
- //fix for 2 digit year
- if year>0 then
- if year<90 then inc(year,2000)
- else
- if year <100 then inc(year,1900);
+ // fix for 2 digit year
+ if Year > 0 then
+ if Year < 90 then
+ inc(Year, 2000)
+ else if Year < 100 then
+ inc(Year, 1900);
//
- DayTable:=@MonthDays[IsLeapYear(Year)];
- for i:=1 to Month-1 do Inc(Day,DayTable^[i]);
- I := Year - 1;
- D := I * 365 + I div 4 - I div 100 + I div 400 + Day - (1969*365 + 492 - 19 + 4 +1);
- DT:= (D*24*60*60) + (Hour*3600+Min*60+Sec);
- //Приводим к GMT...судя по всему миранда хранит таймштампы в GMT
- if toGMT then Result := DT -(PluginLink.CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,DT,0)-DT)
- else Result := DT;
+ DayTable := @MonthDays[IsLeapYear(Year)];
+ for i := 1 to Month - 1 do
+ inc(Day, DayTable^[i]);
+ i := Year - 1;
+ D := i * 365 + i div 4 - i div 100 + i div 400 + Day -
+ (1969 * 365 + 492 - 19 + 4 + 1);
+ DT := (D * 24 * 60 * 60) + (Hour * 3600 + Min * 60 + Sec);
+ // Приводим к GMT...судя по всему миранда хранит таймштампы в GMT
+ if toGMT then
+ Result := DT - (Longword(CallService(MS_DB_TIME_TIMESTAMPTOLOCAL, DT, 0)) - DT)
+ else
+ Result := DT;
end;
-function DateTimeToTimeStamp(const DateTime: TDateTime; toGMT: boolean = true): DWord;
+function DateTimeToTimeStamp(const DateTime: TDateTime; toGMT: Boolean = true): DWord;
begin
- Result := Round((DateTime-UnixDateDelta) * SecsPerDay);
- if toGMT then Result := Result -(PluginLink.CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,Result,0)-Result);
+ Result := Round((DateTime - UnixDateDelta) * SecsPerDay);
+ if toGMT then
+ Result := Result - (Dword(CallService(MS_DB_TIME_TIMESTAMPTOLOCAL, Result, 0)) - Result);
end;
-function ChangeUnicode(str:PWideChar):PWideChar;
+function ChangeUnicode(str: PWideChar): PWideChar;
var
- i,len:integer;
+ i, len: integer;
begin
- result:=str;
- if str=nil then
+ Result := str;
+ if str = nil then
exit;
- if (word(str^)=$FFFE) or (word(str^)=$FEFF) then
+ if (Word(str^) = $FFFE) or (Word(str^) = $FEFF) then
begin
- len:=lstrlenw(str);
- if word(str^)=$FFFE then
+ len := lstrlenw(str);
+ if Word(str^) = $FFFE then
begin
- i:=len-1;
- while i>0 do // str^<>#0
+ i := len - 1;
+ while i > 0 do // str^<>#0
begin
- pword(str)^:=swap(pword(str)^);
+ pword(str)^ := swap(pword(str)^);
inc(str);
dec(i);
end;
-// str:=result;
+ // str:=result;
end;
- move((result+1)^,result^,len*SizeOf(WideChar));
+ move((Result + 1)^, Result^, len * SizeOf(WideChar));
end;
end;
-function WideToANSI(src:PWideChar;var dst:PChar; cp:dword=CP_ACP):PChar;
+function WideToANSI(src: PWideChar; var dst: PAnsiChar; cp: DWord = CP_ACP): PAnsiChar;
var
- len,l:integer;
+ len, l: integer;
begin
- if (src=nil) or (src^=#0) then
+ if (src = nil) or (src^ = #0) then
begin
- GetMem(dst,1);
- dst^:=#0;
+ GetMem(dst, 1);
+ dst^ := #0;
end
else
begin
- l:=lstrlenw(src);
- len:=WideCharToMultiByte(cp,0,src,l,NIL,0,NIL,NIL)+1;
- GetMem(dst,len);
- FillChar(dst^,len,0);
- WideCharToMultiByte(cp,0,src,l,dst,len,NIL,NIL);
+ l := lstrlenw(src);
+ len := WideCharToMultiByte(cp, 0, src, l, NIL, 0, NIL, NIL) + 1;
+ GetMem(dst, len);
+ FillChar(dst^, len, 0);
+ WideCharToMultiByte(cp, 0, src, l, dst, len, NIL, NIL);
end;
- result:=dst;
+ Result := dst;
end;
-function ANSIToWide(src:PChar;var dst:PWideChar; cp:dword=CP_ACP):PWideChar;
+function ANSIToWide(src: PAnsiChar; var dst: PWideChar; cp: DWord = CP_ACP): PWideChar;
var
- len,l:integer;
+ len, l: integer;
begin
- if (src=nil) or (src^=#0) then
+ if (src = nil) or (src^ = #0) then
begin
- GetMem(dst,SizeOf(WideChar));
- dst^:=#0;
+ GetMem(dst, SizeOf(WideChar));
+ dst^ := #0;
end
else
begin
- l:=lstrlen(src);
- len:=MultiByteToWideChar(cp,0,src,l,NIL,0)+1;
- GetMem(dst,len*SizeOf(WideChar));
- FillChar(dst^,len*SizeOf(WideChar),0);
- MultiByteToWideChar(cp,0,src,l,dst,len);
+ l := lstrlena(src);
+ len := MultiByteToWideChar(cp, 0, src, l, NIL, 0) + 1;
+ GetMem(dst, len * SizeOf(WideChar));
+ FillChar(dst^, len * SizeOf(WideChar), 0);
+ MultiByteToWideChar(cp, 0, src, l, dst, len);
end;
- result:=dst;
+ Result := dst;
end;
-function ANSIToUTF8(src:PChar;var dst:pChar;cp:dword=CP_ACP):PChar;
+function ANSIToUTF8(src: PAnsiChar; var dst: PAnsiChar; cp: DWord = CP_ACP): PAnsiChar;
var
- tmp:PWideChar;
+ tmp: PWideChar;
begin
- AnsiToWide(src,tmp,cp);
- result:=WideToUTF8(tmp,dst);
+ ANSIToWide(src, tmp, cp);
+ Result := WidetoUTF8(tmp, dst);
FreeMem(tmp);
end;
-function UTF8Len(src:PChar):integer; // w/o zero
+function UTF8Len(src: PAnsiChar): integer; // w/o zero
begin
- result:=0;
- if src<>nil then
+ Result := 0;
+ if src <> nil then
begin
- while src^<>#0 do
+ while src^ <> #0 do
begin
- if (ord(src^) and $80)=0 then
- else if (ord(src^) and $E0)=$E0 then
- inc(src,2)
+ if (ord(src^) and $80) = 0 then
+ else if (ord(src^) and $E0) = $E0 then
+ inc(src, 2)
else
inc(src);
- inc(result);
+ inc(Result);
inc(src);
end;
end;
end;
-function CalcUTF8Len(src:pWideChar):integer;
+function CalcUTF8Len(src: PWideChar): integer;
begin
- result:=0;
- if src<>nil then
+ Result := 0;
+ if src <> nil then
begin
- while src^<>#0 do
+ while src^ <> #0 do
begin
- if src^<#$0080 then
- else if src^<#$0800 then
- inc(result)
+ if src^ < #$0080 then
+ else if src^ < #$0800 then
+ inc(Result)
else
- inc(result,2);
+ inc(Result, 2);
inc(src);
- inc(result);
+ inc(Result);
end;
end;
end;
-function UTF8toWide(src:PChar; var dst:PWideChar; len:cardinal=dword(-1)):PWideChar;
+function UTF8toWide(src: PAnsiChar; var dst: PWideChar; len: cardinal = DWord(-1)): PWideChar;
var
- w:word;
- p:PWideChar;
+ w: Word;
+ p: PWideChar;
begin
- GetMem(dst,(UTF8Len(src)+1)*SizeOf(WideChar));
- p:=dst;
- if src<>nil then
+ GetMem(dst, (UTF8Len(src) + 1) * SizeOf(WideChar));
+ p := dst;
+ if src <> nil then
begin
- while (src^<>#0) and (len>0) do
+ while (src^ <> #0) and (len > 0) do
begin
- if ord(src^)<$80 then
- w:=ord(src^)
- else if (ord(src^) and $E0)=$E0 then
+ if ord(src^) < $80 then
+ w := ord(src^)
+ else if (ord(src^) and $E0) = $E0 then
begin
- w:=(ord(src^) and $1F) shl 12;
- inc(src); dec(len);
- w:=w or (((ord(src^))and $3F) shl 6);
- inc(src); dec(len);
- w:=w or (ord(src^) and $3F);
+ w := (ord(src^) and $1F) shl 12;
+ inc(src);
+ dec(len);
+ w := w or (((ord(src^)) and $3F) shl 6);
+ inc(src);
+ dec(len);
+ w := w or (ord(src^) and $3F);
end
else
begin
- w:=(ord(src^) and $3F) shl 6;
- inc(src); dec(len);
- w:=w or (ord(src^) and $3F);
+ w := (ord(src^) and $3F) shl 6;
+ inc(src);
+ dec(len);
+ w := w or (ord(src^) and $3F);
end;
- p^:=WideChar(w);
+ p^ := WideChar(w);
inc(p);
- inc(src); dec(len);
+ inc(src);
+ dec(len);
end;
end;
- p^:=#0;
- result:=dst;
+ p^ := #0;
+ Result := dst;
end;
-function UTF8toANSI(src:PChar;var dst:PChar;cp:dword=CP_ACP):PChar;
+function UTF8toANSI(src: PAnsiChar; var dst: PAnsiChar; cp: DWord = CP_ACP): PAnsiChar;
var
- tmp:pWideChar;
+ tmp: PWideChar;
begin
- UTF8ToWide(src,tmp);
- result:=WideToAnsi(tmp,dst,cp);
+ UTF8toWide(src, tmp);
+ Result := WideToANSI(tmp, dst, cp);
FreeMem(tmp);
end;
-function WidetoUTF8(src:PWideChar; var dst:PChar):PChar;
+function WidetoUTF8(src: PWideChar; var dst: PAnsiChar): PAnsiChar;
var
- p:PChar;
+ p: PAnsiChar;
begin
- GetMem(dst,CalcUTF8Len(src)+1);
- p:=dst;
- if src<>nil then
+ GetMem(dst, CalcUTF8Len(src) + 1);
+ p := dst;
+ if src <> nil then
begin
- while src^<>#0 do
+ while src^ <> #0 do
begin
- if src^<#$0080 then
- p^:=Char(src^)
- else if src^<#$0800 then
+ if src^ < #$0080 then
+ p^ := AnsiChar(src^)
+ else if src^ < #$0800 then
begin
- p^:=chr($C0 or (ord(src^) shr 6));
+ p^ := AnsiChar($C0 or (ord(src^) shr 6));
inc(p);
- p^:=chr($80 or (ord(src^) and $3F));
+ p^ := AnsiChar($80 or (ord(src^) and $3F));
end
else
begin
- p^:=chr($E0 or (ord(src^) shr 12));
+ p^ := AnsiChar($E0 or (ord(src^) shr 12));
inc(p);
- p^:=chr($80 or ((ord(src^) shr 6) and $3F));
+ p^ := AnsiChar($80 or ((ord(src^) shr 6) and $3F));
inc(p);
- p^:=chr($80 or (ord(src^) and $3F));
+ p^ := AnsiChar($80 or (ord(src^) and $3F));
end;
inc(p);
inc(src);
end;
end;
- p^:=#0;
- result:=dst;
+ p^ := #0;
+ Result := dst;
end;
end.
diff --git a/plugins/ImportTXT/ImportThrd.pas b/plugins/ImportTXT/ImportThrd.pas
index 4da1eae5b0..245276c040 100644
--- a/plugins/ImportTXT/ImportThrd.pas
+++ b/plugins/ImportTXT/ImportThrd.pas
@@ -12,588 +12,638 @@ uses
general,
ImportT,
ImportTU,
- KOLEdb
- ;
-
-
-
-const ITXT_THREAD_BASE = $8000+$2000;//WM_APP + $2000
- ITXT_THREAD_START = ITXT_THREAD_BASE+1; //Поток запустился (0,0)
- ITXT_THREAD_MAXPROGRESS = ITXT_THREAD_BASE+2; // Мах прогресс (0, MaxProgress)
- ITXT_THREAD_PROGRESS = ITXT_THREAD_BASE+3; //Прогресс (Current, 0)
- ITXT_THREAD_ERROR = ITXT_THREAD_BASE+4; //Возникла ошибка (PWideChar(ErrorString),0)
- ITXT_THREAD_FINISH = ITXT_THREAD_BASE+5; //Завершение файла, подведение результатов (Added, Duplicates)
- ITXT_THREAD_START_FILE = ITXT_THREAD_BASE+6; //Начали работать с файлом(PWideChar(FileName),0);
- ITXT_THREAD_DEST_CONTACT = ITXT_THREAD_BASE+7; //Определили контакт (hContact,0)
- ITXT_THREAD_ALLSTARTED = ITXT_THREAD_BASE+8; //Началось
- ITXT_THREAD_ALLFINISHED = ITXT_THREAD_BASE+9; //Всё закончено :)
+ KOLEdb;
+
+const
+ ITXT_THREAD_BASE = $8000 + $2000; // WM_APP + $2000
+ ITXT_THREAD_START = ITXT_THREAD_BASE + 1; // Поток запустился (0,0)
+ ITXT_THREAD_MAXPROGRESS = ITXT_THREAD_BASE + 2;
+ // Мах прогресс (0, MaxProgress)
+ ITXT_THREAD_PROGRESS = ITXT_THREAD_BASE + 3; // Прогресс (Current, 0)
+ ITXT_THREAD_ERROR = ITXT_THREAD_BASE + 4;
+ // Возникла ошибка (PWideChar(ErrorString),0)
+ ITXT_THREAD_FINISH = ITXT_THREAD_BASE + 5;
+ // Завершение файла, подведение результатов (Added, Duplicates)
+ ITXT_THREAD_START_FILE = ITXT_THREAD_BASE + 6;
+ // Начали работать с файлом(PWideChar(FileName),0);
+ ITXT_THREAD_DEST_CONTACT = ITXT_THREAD_BASE + 7;
+ // Определили контакт (hContact,0)
+ ITXT_THREAD_ALLSTARTED = ITXT_THREAD_BASE + 8; // Началось
+ ITXT_THREAD_ALLFINISHED = ITXT_THREAD_BASE + 9; // Всё закончено :)
type
- TSendMethod = (smSend,smPost);
+ TSendMethod = (smSend, smPost);
type
TImportThrd = class(TThread)
private
{ Private declarations }
- RegExpr:TPerlRegEx;
- hMapedFile:THandle;
- hFile:THandle;
- pFileText:Pointer;
- FolderName:WideString;
- FileName:WideString;
- FileLen:Cardinal;
- fContact:TDestContact; //Contact recognised by filename
+ RegExpr: TPerlRegEx;
+ hMapedFile: THandle;
+ hFile: THandle;
+ pFileText: Pointer;
+ FolderName: WideString;
+ FileName: WideString;
+ FileLen: Cardinal;
+ fContact: TDestContact; // Contact recognised by filename
AddedMessages: integer;
Duplicates: integer;
- function DoMessage(Message: Longword; wParam: WPARAM; lParam: LPARAM; Method: TSendMethod = smSend): Boolean;
- function DoMapFile:boolean;
+ function DoMessage(Message: Longword; wParam: WPARAM; lParam: LPARAM;
+ Method: TSendMethod = smSend): Boolean;
+ function DoMapFile: Boolean;
procedure DoUnMapFile;
- Procedure PreMessageSP(var src:string; CSP:integer);
- procedure AddMsgToDB(hContact:Thandle; Direction:integer; MsgTimeStamp:LongWord; const Text: string;
- var AddMsg,Dupy:integer);
+ Procedure PreMessageSP(var src: AnsiString; CSP: integer);
+ procedure AddMsgToDB(hContact: THandle; Direction: integer;
+ MsgTimeStamp: Longword; const Text: AnsiString; var AddMsg, Dupy: integer);
procedure TextImportProcedure;
- procedure BinImportProcedure;
+ procedure BinImportProcedure;
protected
procedure Execute; override;
public
- FileNames:WideString; //File Names
- OffsetFileName:integer; //offset name of file in FileNames
- WorkPattern:RTxtPattern; // Pattern for work
- DContact:TDestContact; //Recognised or defined contact
- Destination:TDestProto; // destination protocol
- ParentHWND:LongWord; //HWND of parent window
+ FileNames: WideString; // File Names
+ OffsetFileName: integer; // offset name of file in FileNames
+ WorkPattern: RTxtPattern; // Pattern for work
+ DContact: TDestContact; // Recognised or defined contact
+ Destination: TDestProto; // destination protocol
+ ParentHWND: Longword; // HWND of parent window
end;
+function IsDuplicateEvent(hContact: THandle; dbei: TDBEVENTINFO): Boolean;
-function IsDuplicateEvent(hContact:THandle; dbei:TDBEVENTINFO):boolean;
-
-function PassMessage(Handle: THandle; Message: LongWord; wParam: WPARAM; lParam: LPARAM; Method: TSendMethod = smSend): Boolean;
-
+function PassMessage(Handle: THandle; Message: Longword; wParam: wParam;
+ lParam: lParam; Method: TSendMethod = smSend): Boolean;
implementation
-
// Returns TRUE if event already is in base
-function IsDuplicateEvent(hContact:THandle; dbei:TDBEVENTINFO):boolean;
+function IsDuplicateEvent(hContact: THandle; dbei: TDBEVENTINFO): Boolean;
var
- hExistingDbEvent:THandle;
- dbeiExisting:TDBEVENTINFO;
- dwFirstEventTimeStamp:LongWord;
- dwLastEventTimeStamp:LongWord;
- dwPreviousTimeStamp:LongWord;
+ hExistingDbEvent: THandle;
+ dbeiExisting: TDBEVENTINFO;
+ dwFirstEventTimeStamp: Longword;
+ dwLastEventTimeStamp: Longword;
+ dwPreviousTimeStamp: Longword;
begin
- result:=FALSE;
- if not CheckForDuplicates then exit;
- hExistingDbEvent:=pluginLink^.CallService(MS_DB_EVENT_FINDFIRST, hContact, 0);
- if hExistingDbEvent=0 then begin Result:=False; exit; end;
+ result := FALSE;
+ if not CheckForDuplicates then
+ exit;
+ hExistingDbEvent := CallService(MS_DB_EVENT_FINDFIRST, hContact, 0);
+ if hExistingDbEvent = 0 then
+ begin
+ result := FALSE;
+ exit;
+ end;
FillChar(dbeiExisting, SizeOf(dbeiExisting), Byte(0));
- dbeiExisting.cbSize:= sizeof(dbeiExisting);
- dbeiExisting.cbBlob:= 0;
- pluginLink^.CallService(MS_DB_EVENT_GET, wParam(hExistingDbEvent), lParam(@dbeiExisting));
- dwFirstEventTimeStamp:=dbeiExisting.timestamp;
-
- hExistingDbEvent:=pluginLink^.CallService(MS_DB_EVENT_FINDLAST, wParam(hContact), lParam(0));
- if hExistingDbEvent=0 then begin Result:=False; exit; end;
+ dbeiExisting.cbSize := SizeOf(dbeiExisting);
+ dbeiExisting.cbBlob := 0;
+ CallService(MS_DB_EVENT_GET, wParam(hExistingDbEvent), lParam(@dbeiExisting));
+ dwFirstEventTimeStamp := dbeiExisting.timestamp;
+
+ hExistingDbEvent := CallService(MS_DB_EVENT_FINDLAST, wParam(hContact),
+ lParam(0));
+ if hExistingDbEvent = 0 then
+ begin
+ result := FALSE;
+ exit;
+ end;
FillChar(dbeiExisting, SizeOf(dbeiExisting), Byte(0));
- dbeiExisting.cbSize:= sizeof(dbeiExisting);
- dbeiExisting.cbBlob:= 0;
- pluginLink^.CallService(MS_DB_EVENT_GET, wParam(hExistingDbEvent), lParam(@dbeiExisting));
- dwLastEventTimeStamp:=dbeiExisting.timestamp;
+ dbeiExisting.cbSize := SizeOf(dbeiExisting);
+ dbeiExisting.cbBlob := 0;
+ CallService(MS_DB_EVENT_GET, wParam(hExistingDbEvent), lParam(@dbeiExisting));
+ dwLastEventTimeStamp := dbeiExisting.timestamp;
- // If before the first
- if (dbei.timestamp < dwFirstEventTimeStamp) then begin Result:=False; exit; end;
+ // If before the first
+ if (dbei.timestamp < dwFirstEventTimeStamp) then
+ begin
+ result := FALSE;
+ exit;
+ end;
- // If after the last
- if (dbei.timestamp > dwLastEventTimeStamp) then begin Result:=False; exit; end;
+ // If after the last
+ if (dbei.timestamp > dwLastEventTimeStamp) then
+ begin
+ result := FALSE;
+ exit;
+ end;
- dwPreviousTimeStamp:=dwLastEventTimeStamp;
+ dwPreviousTimeStamp := dwLastEventTimeStamp;
- if (dbei.timestamp <= dwPreviousTimeStamp) then // search from the end
- begin
- while (hExistingDbEvent <> 0) do
+ if (dbei.timestamp <= dwPreviousTimeStamp) then // search from the end
+ begin
+ while (hExistingDbEvent <> 0) do
+ begin
+ FillChar(dbeiExisting, SizeOf(dbeiExisting), Byte(0));
+ dbeiExisting.cbSize := SizeOf(dbeiExisting);
+ dbeiExisting.cbBlob := 0;
+ CallService(MS_DB_EVENT_GET, wParam(hExistingDbEvent),
+ lParam(@dbeiExisting));
+ // compare event
+ if (dbei.timestamp = dbeiExisting.timestamp) and
+ ((dbei.flags) = (dbeiExisting.flags and not DBEF_FIRST)) and
+ // fix for first event
+ (dbei.eventType = dbeiExisting.eventType) and
+ (dbei.cbBlob = dbeiExisting.cbBlob) then
begin
- FillChar(dbeiExisting, SizeOf(dbeiExisting), Byte(0));
- dbeiExisting.cbSize:= sizeof(dbeiExisting);
- dbeiExisting.cbBlob:= 0;
- pluginLink^.CallService(MS_DB_EVENT_GET, wParam(hExistingDbEvent), lParam(@dbeiExisting));
- // compare event
- if ( dbei.timestamp = dbeiExisting.timestamp ) and
- ( (dbei.flags) = (dbeiExisting.flags and not DBEF_FIRST)) and //fix for first event
- (dbei.eventType = dbeiExisting.eventType) and
- (dbei.cbBlob = dbeiExisting.cbBlob) then begin Result:=true; exit; end;
-
- if (dbei.timestamp > dbeiExisting.timestamp) then begin Result:=False; exit; end;
- // get the previous
- hExistingDbEvent:=pluginLink^.CallService(MS_DB_EVENT_FINDPREV, wParam(hExistingDbEvent), 0);
+ result := true;
+ exit;
end;
- end;
-end;
+ if (dbei.timestamp > dbeiExisting.timestamp) then
+ begin
+ result := FALSE;
+ exit;
+ end;
+ // get the previous
+ hExistingDbEvent := CallService(MS_DB_EVENT_FINDPREV,
+ wParam(hExistingDbEvent), 0);
+ end;
+ end;
+end;
-Procedure TImportThrd.PreMessageSP(var src:string; CSP:integer);
-var i:integer;
- ls:integer;
- PSP,ASP:integer;
+Procedure TImportThrd.PreMessageSP(var src: AnsiString; CSP: integer);
+var
+ i: integer;
+ ls: integer;
+ PSP, ASP: integer;
begin
- ls:=-1;
+ ls := -1;
repeat
- i:=ls+2;
- PSP:=0;
- while (src[i+PSP]=' ') do inc(PSP);
- if PSP>0 then
- case WorkPattern.PreMsg.PreSP of
- 0: PSP:=0;
- -1: ;
- -2: if PSP>CSP then PSP:=CSP;
- else if PSP>WorkPattern.PreMsg.PreSP then PSP:=WorkPattern.PreMsg.PreSP;
- end; //case
- Delete(src,i,PSP);
- ls:=PosEx(#$0D#$0A,src,i);
- ASP:=0;
- while (ls>1) and (src[ls-ASP-1]=' ') do inc(ASP);
- if ASP>0 then
- case WorkPattern.PreMsg.AfterSP of
- 0: ASP:=0;
- -1: ;
- -2: if ASP>CSP then ASP:=CSP;
- else if ASP>WorkPattern.PreMsg.AfterSP then ASP:=WorkPattern.PreMsg.AfterSP;
- end; //case
- Delete(src,ls-ASP-1,ASP);
- Until ls<=0
+ i := ls + 2;
+ PSP := 0;
+ while (src[i + PSP] = ' ') do
+ inc(PSP);
+ if PSP > 0 then
+ case WorkPattern.PreMsg.PreSP of
+ 0: PSP := 0;
+ -1: ;
+ -2: if PSP > CSP then
+ PSP := CSP;
+ else
+ if PSP > WorkPattern.PreMsg.PreSP then
+ PSP := WorkPattern.PreMsg.PreSP;
+ end; // case
+ Delete(src, i, PSP);
+ ls := PosEx(#$0D#$0A, src, i);
+ ASP := 0;
+ while (ls > 1) and (src[ls - ASP - 1] = ' ') do
+ inc(ASP);
+ if ASP > 0 then
+ case WorkPattern.PreMsg.AfterSP of
+ 0: ASP := 0;
+ -1: ;
+ -2: if ASP > CSP then
+ ASP := CSP;
+ else
+ if ASP > WorkPattern.PreMsg.AfterSP then
+ ASP := WorkPattern.PreMsg.AfterSP;
+ end; // case
+ Delete(src, ls - ASP - 1, ASP);
+ Until ls <= 0
end;
-Procedure TImportThrd.AddMsgToDB(hContact:Thandle; Direction:integer;MsgTimeStamp:LongWord; const Text: string;
- var AddMsg,Dupy:integer);
-var dbei:TDBEVENTINFO;
- proto:string;
- s:WideString;
+Procedure TImportThrd.AddMsgToDB(hContact: THandle; Direction: integer;
+ MsgTimeStamp: Longword; const Text: AnsiString; var AddMsg, Dupy: integer);
+var
+ dbei: TDBEVENTINFO;
+ proto: AnsiString;
+ s: WideString;
begin
FillChar(dbei, SizeOf(dbei), Byte(0));
- dbei.cbSize:= sizeof(dbei);
- dbei.eventType:= EVENTTYPE_MESSAGE;
- dbei.flags:=direction;
- proto:=GetContactProto(hContact);
- dbei.szModule:= PAnsiChar(proto);
- dbei.timestamp:=MsgTimeStamp;
- dbei.cbBlob:=Length(Text)+1;
- dbei.pBlob:=PByte(AllocMem(dbei.cbBlob));
+ dbei.cbSize := SizeOf(dbei);
+ dbei.eventType := EVENTTYPE_MESSAGE;
+ dbei.flags := Direction;
+ proto := GetContactProto(hContact);
+ dbei.szModule := PAnsiChar(proto);
+ dbei.timestamp := MsgTimeStamp;
+ dbei.cbBlob := Length(Text) + 1;
+ dbei.pBlob := PByte(AllocMem(dbei.cbBlob));
try
- Move(Text[1],dbei.pBlob^,dbei.cbBlob);
- if not IsDuplicateEvent(hContact,dbei) then
- if pluginLink^.CallService(MS_DB_EVENT_ADD, wParam(hContact), lParam(@dbei))<>0 then Inc(AddMsg)
- else begin
- s:= 'Error adding message to DB';
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0); end
-
- else
- begin
- if ShowDuplicates then
- begin
- if (dbei.flags and DBEF_SENT)>0 then s:='>'
- else s:='<';
- s:=TranslateWideString('Duplicate:')+' '+s+' '+TimeStampToWStr(dbei.timestamp);
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0,smSend);
- end;
- Inc(Dupy);
- end;
+ Move(Text[1], dbei.pBlob^, dbei.cbBlob);
+ if not IsDuplicateEvent(hContact, dbei) then
+ if CallService(MS_DB_EVENT_ADD, wParam(hContact), lParam(@dbei)) <> 0 then
+ inc(AddMsg)
+ else
+ begin
+ s := 'Error adding message to DB';
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ end
+ else
+ begin
+ if ShowDuplicates then
+ begin
+ if (dbei.flags and DBEF_SENT) > 0 then
+ s := '>'
+ else
+ s := '<';
+ s := TranslateWideString('Duplicate:') + ' ' + s + ' ' +
+ TimeStampToWStr(dbei.timestamp);
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0, smSend);
+ end;
+ inc(Dupy);
+ end;
finally
- FreeMem(dbei.pBlob);
+ FreeMem(dbei.pBlob);
end;
end;
-function PassMessage(Handle: THandle; Message: LongWord; wParam: WPARAM; lParam: LPARAM; Method: TSendMethod = smSend): Boolean;
+function PassMessage(Handle: THandle; Message: Longword; wParam: wParam;
+ lParam: lParam; Method: TSendMethod = smSend): Boolean;
var
Tries: integer;
begin
- Result := True;
+ result := true;
case Method of
- smSend: SendMessage(Handle,Message,wParam,lParam);
- smPost: begin
+ smSend:
+ SendMessage(Handle, Message, wParam, lParam);
+ smPost: begin
Tries := 5;
- while (Tries > 0) and not PostMessage(Handle,Message,wParam,lParam) do begin
+ while (Tries > 0) and not PostMessage(Handle, Message, wParam,
+ lParam) do
+ begin
Dec(Tries);
Sleep(5);
end;
- Result := (Tries > 0);
+ result := (Tries > 0);
end;
end;
end;
-function TImportThrd.DoMessage(Message: LongWord; wParam: WPARAM; lParam: LPARAM; Method: TSendMethod = smSend): Boolean;
+function TImportThrd.DoMessage(Message: Longword; wParam: wParam;
+ lParam: lParam; Method: TSendMethod = smSend): Boolean;
begin
- Result := PassMessage(ParentHWND,Message,wParam,lParam,Method);
+ result := PassMessage(ParentHWND, Message, wParam, lParam, Method);
end;
-function TImportThrd.DoMapFile:boolean;
-var s:WideString;
+function TImportThrd.DoMapFile: Boolean;
+var
+ s: pWideChar;
begin
- result:=true;
- hFile:=CreateFileW(PWideChar(FileName),GENERIC_READ,0,nil,OPEN_EXISTING,0,0);
- if hFile=INVALID_HANDLE_VALUE then
- begin
- result:=false;
- s:='Error opening file';
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
- exit;
- end;
- FileLen:=GetFileSize(hFile,nil);
- hMapedFile:=CreateFileMapping(hFile,nil,PAGE_READONLY,0,0,'ImportTXTmapfile');
- if hMapedFile=0 then
- begin
- result:=false;
- s:= 'Error mapping file';
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
- exit;
- end;
- pFileText:=MapViewOfFile(hMapedFile,FILE_MAP_READ,0,0,0);
- if pFileText=nil then
- begin
- result:=false;
- s:='Error mapping';
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
- exit;
- end;
+ result := true;
+ hFile := CreateFileW(PWideChar(FileName), GENERIC_READ, 0, nil,
+ OPEN_EXISTING, 0, 0);
+ if hFile = INVALID_HANDLE_VALUE then
+ begin
+ result := FALSE;
+ s := 'Error opening file';
+ DoMessage(ITXT_THREAD_ERROR, wparam(s), 0);
+ exit;
+ end;
+ FileLen := GetFileSize(hFile, nil);
+ hMapedFile := CreateFileMapping(hFile, nil, PAGE_READONLY, 0, 0, 'ImportTXTmapfile');
+ if hMapedFile = 0 then
+ begin
+ result := FALSE;
+ s := 'Error mapping file';
+ DoMessage(ITXT_THREAD_ERROR, wparam(s), 0);
+ exit;
+ end;
+ pFileText := MapViewOfFile(hMapedFile, FILE_MAP_READ, 0, 0, 0);
+ if pFileText = nil then
+ begin
+ result := FALSE;
+ s := 'Error mapping';
+ DoMessage(ITXT_THREAD_ERROR, wparam(s), 0);
+ exit;
+ end;
end;
procedure TImportThrd.DoUnMapFile;
begin
- UnmapViewOfFile(pFileText);
- pFileText:=nil;
- CloseHandle(hMapedFile);
- CloseHandle(hFile);
+ UnmapViewOfFile(pFileText);
+ pFileText := nil;
+ CloseHandle(hMapedFile);
+ CloseHandle(hFile);
end;
-procedure TryDetermContact(var dContact:TDestContact);
+procedure TryDetermContact(var DContact: TDestContact);
begin
- if dContact.ProtoName<>'' then
+ if DContact.ProtoName <> '' then
begin
- if dContact.ContactUID<>'' then
- begin
- dContact.hContact:=GetContactByUID(dContact.ProtoName,dContact.ContactUID)
- end
- else
- if dContact.ContactNick<>'' then
- begin
- dContact.hContact:=GetContactByNick(dContact.ProtoName,dContact.ContactNick);
- end
- else
- dContact.hContact:=INVALID_HANDLE_VALUE;
+ if DContact.ContactUID <> '' then
+ begin
+ DContact.hContact := GetContactByUID(DContact.ProtoName, DContact.ContactUID)
+ end
+ else if DContact.ContactNick <> '' then
+ begin
+ DContact.hContact := GetContactByNick(DContact.ProtoName, DContact.ContactNick);
+ end
+ else
+ DContact.hContact := INVALID_HANDLE_VALUE;
end
- else
- dContact.hContact:=INVALID_HANDLE_VALUE;
+ else
+ DContact.hContact := INVALID_HANDLE_VALUE;
end;
procedure TImportThrd.TextImportProcedure;
var
- PosCur,LenCur,PosNext:integer;
- TextLength,
- h1,h2:integer;
- PRN,ARN,j:DWORD;
- msg_flag:integer;
- DT:LongWord;
- TxtMsg:string;
- s:WideString;
- tempstr:PChar;
- tempwstr:PWideChar;
+ PosCur, LenCur, PosNext: integer;
+ TextLength, h1, h2: integer;
+ PRN, ARN, j: DWORD;
+ msg_flag: integer;
+ DT: Longword;
+ TxtMsg: AnsiString;
+ s: WideString;
+ tempstr: PAnsiChar;
+ tempwstr: PWideChar;
begin
- AddedMessages:=0;
- Duplicates:=0;
- Case WorkPattern.Charset of
- inANSI:if IsMirandaUnicode then
- begin
- if WorkPattern.Codepage<>0 then tempstr:=ANSIToUTF8(PAnsiChar(pFileText),tempstr,WorkPattern.Codepage)
- else tempstr:=ANSIToUTF8(PAnsiChar(pFileText),tempstr,cp);
- RegExpr.Subject:=tempstr;
- FreeMem(tempstr);
- end
- else RegExpr.Subject:=PAnsiChar(pFileText);
- inUTF8:if IsMirandaUnicode then RegExpr.Subject:=PChar(pFileText)+3
- else
- begin
- tempstr:=UTF8ToANSI(PChar(pFileText)+3,tempstr,cp);
- RegExpr.Subject:=tempstr;
- FreeMem(tempstr);
- end;
- inUCS2:begin
- GetMem(tempwstr,FileLen+2);
- lstrcpynW(tempwstr,PWideChar(pFileText),FileLen);
- tempwstr[FileLen div SizeOf(WideChar)]:=#$0000; //file is not ended dy #0000
- if IsMirandaUnicode then tempstr:=WidetoUTF8(ChangeUnicode(tempwstr),tempstr)
- else tempstr:=WideToANSI(ChangeUnicode(tempwstr),tempstr,cp);
- RegExpr.Subject:=tempstr;
- FreeMem(tempstr);
- FreeMem(tempwstr);
- end;
- end; //case
- if (WorkPattern.UseHeader and 1)=0 then //If the information on a direction is not present that we will transform a line
- begin
- if IsMirandaUnicode then
- begin
- tempstr:=ANSIToUTF8(PAnsiChar(WorkPattern.Msg.Incoming),tempstr,cp);
- WorkPattern.Msg.Incoming:=tempstr;
- FreeMem(tempstr);
- tempstr:=ANSIToUTF8(PAnsiChar(WorkPattern.Msg.Outgoing),tempstr,cp);
- WorkPattern.Msg.Outgoing:=tempstr;
- FreeMem(tempstr);
- end
- end;
- if (WorkPattern.UseHeader>0) then
- begin
- if IsMirandaUnicode then
- begin
- tempstr:=ANSIToUTF8(PAnsiChar(WorkPattern.Header.Pattern),tempstr,cp);
- RegExpr.RegEx:=tempstr;
- RegExpr.Options:=[preMultiLine, preUTF8];
- FreeMem(tempstr);
- end
- else
- begin
- RegExpr.RegEx:=WorkPattern.Header.Pattern;
- RegExpr.Options:=[preMultiLine];
- end;
+ AddedMessages := 0;
+ Duplicates := 0;
+ Case WorkPattern.Charset of
+ inANSI:
+ begin
+ if WorkPattern.Codepage <> 0 then
+ tempstr := ANSIToUTF8(PAnsiChar(pFileText), tempstr, WorkPattern.Codepage)
+ else
+ tempstr := ANSIToUTF8(PAnsiChar(pFileText), tempstr, cp);
+ RegExpr.Subject := tempstr;
+ FreeMem(tempstr);
+ end;
+ inUTF8:
+ RegExpr.Subject := PAnsiChar(pFileText) + 3;
+ inUCS2:
+ begin
+ GetMem(tempwstr, FileLen + 2);
+ lstrcpynW(tempwstr, PWideChar(pFileText), FileLen);
+ tempwstr[FileLen div SizeOf(WideChar)] := #$0000;
+ // file is not ended dy #0000
+ tempstr := WidetoUTF8(ChangeUnicode(tempwstr), tempstr);
+ RegExpr.Subject := tempstr;
+ FreeMem(tempstr);
+ FreeMem(tempwstr);
+ end;
+ end; // case
+ if (WorkPattern.UseHeader and 1) = 0 then
+ // If the information on a direction is not present that we will transform a line
+ begin
+ tempstr := ANSIToUTF8(PAnsiChar(WorkPattern.Msg.Incoming), tempstr, cp);
+ WorkPattern.Msg.Incoming := tempstr;
+ FreeMem(tempstr);
+ tempstr := ANSIToUTF8(PAnsiChar(WorkPattern.Msg.Outgoing), tempstr, cp);
+ WorkPattern.Msg.Outgoing := tempstr;
+ FreeMem(tempstr);
+ end;
+ if (WorkPattern.UseHeader > 0) then
+ begin
+ tempstr := ANSIToUTF8(PAnsiChar(WorkPattern.Header.Pattern), tempstr, cp);
+ RegExpr.RegEx := tempstr;
+ RegExpr.Options := [preMultiLine, preUTF8];
+ FreeMem(tempstr);
if not RegExpr.Match then
- begin
- s:=TranslateWideString('Header not found');
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
+ begin
+ s := TranslateWideString('Header not found');
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
exit;
- end
- else
- begin
- if (WorkPattern.UseHeader and 1)=1 then
- begin
- WorkPattern.Msg.Incoming:=RegExpr.SubExpressions[WorkPattern.Header.Incoming];
- WorkPattern.Msg.Outgoing:=RegExpr.SubExpressions[WorkPattern.Header.Outgoing];
- end;
- if (WorkPattern.UseHeader and 2)=2 then
- if (DContact.hContact=0) or (DContact.hContact=INVALID_HANDLE_VALUE) then
+ end
+ else
+ begin
+ if (WorkPattern.UseHeader and 1) = 1 then
+ begin
+ WorkPattern.Msg.Incoming := RegExpr.SubExpressions[WorkPattern.Header.Incoming];
+ WorkPattern.Msg.Outgoing := RegExpr.SubExpressions[WorkPattern.Header.Outgoing];
+ end;
+ if (WorkPattern.UseHeader and 2) = 2 then
+ if (DContact.hContact = 0) or
+ (DContact.hContact = INVALID_HANDLE_VALUE) then
begin
- if WorkPattern.Header.InUID<>0 then DContact.ContactUID:=RegExpr.SubExpressions[WorkPattern.Header.InUID]
- else DContact.ContactUID:='';
- if WorkPattern.Header.InNick<>0 then DContact.ContactNick:=RegExpr.SubExpressions[WorkPattern.Header.InNick]
- else DContact.ContactNick:='';
- TryDetermContact(DContact);
+ if WorkPattern.Header.InUID <> 0 then
+ DContact.ContactUID := RegExpr.SubExpressions[WorkPattern.Header.InUID]
+ else
+ DContact.ContactUID := '';
+ if WorkPattern.Header.InNick <> 0 then
+ DContact.ContactNick := RegExpr.SubExpressions[WorkPattern.Header.InNick]
+ else
+ DContact.ContactNick := '';
+ TryDetermContact(DContact);
end;
- end;
end;
- //Whether if it has not turned out to define in header then we look it was defined in a file
- if (DContact.hContact=0) or (DContact.hContact=INVALID_HANDLE_VALUE) then
- if (fContact.hContact<>0) and (fContact.hContact<>INVALID_HANDLE_VALUE) then
- DContact:=fContact;
- if (DContact.hContact<>0) and (DContact.hContact<>INVALID_HANDLE_VALUE) then
+ end;
+ // Whether if it has not turned out to define in header then we look it was defined in a file
+ if (DContact.hContact = 0) or (DContact.hContact = INVALID_HANDLE_VALUE) then
+ if (fContact.hContact <> 0) and (fContact.hContact <> INVALID_HANDLE_VALUE) then
+ DContact := fContact;
+ if (DContact.hContact <> 0) and (DContact.hContact <> INVALID_HANDLE_VALUE) then
begin
- DoMessage(ITXT_THREAD_DEST_CONTACT,DContact.hContact,0);
- DoMessage(ITXT_THREAD_START,0,0);
- if IsMirandaUnicode then
- begin
- tempstr:=ANSIToUTF8(PAnsiChar(WorkPattern.Msg.Pattern),tempstr,cp);
- RegExpr.RegEx:=tempstr;
- RegExpr.Options:=[preMultiLine, preUTF8];
+ DoMessage(ITXT_THREAD_DEST_CONTACT, DContact.hContact, 0);
+ DoMessage(ITXT_THREAD_START, 0, 0);
+ tempstr := ANSIToUTF8(PAnsiChar(WorkPattern.Msg.Pattern), tempstr, cp);
+ RegExpr.RegEx := tempstr;
+ RegExpr.Options := [preMultiLine, preUTF8];
FreeMem(tempstr);
- end
- else
- begin
- RegExpr.RegEx:=WorkPattern.Msg.Pattern;
- RegExpr.Options:=[preMultiLine];
- end;
-
- TextLength:=Length(RegExpr.Subject)-1; //Position of last symbol
- DoMessage(ITXT_THREAD_MAXPROGRESS,0,TextLength);
- RegExpr.State:=[preNotEmpty];
- //search for regular expression
- if not RegExpr.Match then
- begin
- s:=TranslateWideString('No messages in this file');
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
- end
- else
- begin
- PosCur:=RegExpr.MatchedExpressionOffset; //get the position of RegExpression
- repeat
- LenCur:=RegExpr.MatchedExpressionLength; //get the length of RegExpression
- //Further we define a message direction (incoming or outgoing)
- if RegExpr.SubExpressions[WorkPattern.Msg.Direction]=WorkPattern.Msg.Incoming then msg_flag:=DBEF_READ
- else msg_flag:=DBEF_READ or DBEF_SENT;
- if IsMirandaUnicode then msg_flag:=msg_flag or DBEF_UTF;
- //make timestamp
- if WorkPattern.Msg.Seconds<>0 then
- DT:=TimeStamp(
- StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Year]),
- StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Month]),
- StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Day]),
- StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Hours]),
- StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Minutes]),
- StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Seconds])
- ) else
- DT:=TimeStamp(
- StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Year]),
- StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Month]),
- StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Day]),
- StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Hours]),
- StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Minutes]),
- 0
- );
-
- if RegExpr.MatchAgain then PosNext:=RegExpr.MatchedExpressionOffset //search for next regexpr
- else PosNext:=TextLength; // if not then end of file
- h1:=PosCur+LenCur; //The message text beginning presumably
- h2:=PosNext-PosCur-LenCur-2; //its presumably message length
- //working with message text
- if WorkPattern.UsePreMsg then PRN:=DWORD(WorkPattern.PreMsg.PreRN)
- else PRN:=DWORD(-1);
- if PRN<>0 then
- begin
- j:=1;
- while ((RegExpr.Subject[h1]=Char($0D))and
- (RegExpr.Subject[h1+1]=Char($0A))) and
- (j<=PRN)
- do begin inc(h1,2); dec(h2,2); inc(j); end; //remove carriage return in the beginning
- end;
- if WorkPattern.UsePreMsg then ARN:=DWORD(WorkPattern.PreMsg.AfterRN)
- else ARN:=DWORD(-1);
- if ARN<>0 then
- begin
- j:=1;
- while ((RegExpr.Subject[h1+h2]=Char($0D))and
- (RegExpr.Subject[h1+h2+1]=Char($0A))) and
- (j<=ARN)
- do begin dec(h2,2); inc(j) end; //remove carriage return in the end
- end;
- //get the message text
- TxtMsg:=Copy(RegExpr.Subject,h1,h2+2);
- //remove spaces if needs
- if WorkPattern.UsePreMsg and ((WorkPattern.PreMsg.PreSP<>0) or (WorkPattern.PreMsg.AfterSP<>0)) then
- if IsMirandaUnicode then PreMessageSP(TxtMsg,UTF8Len(PChar(RegExpr.MatchedExpression)))
- else PreMessageSP(TxtMsg,LenCur);
- AddMsgToDB(DContact.hContact,msg_flag,DT,TxtMsg,AddedMessages,Duplicates); //adding in base
- PosCur:=PosNext;
- DoMessage(ITXT_THREAD_PROGRESS,PosCur,0);
- until (PosNext = TextLength) or Terminated ;
- end; //RegExpr.Exec
- end
+
+ TextLength := Length(RegExpr.Subject) - 1; // Position of last symbol
+ DoMessage(ITXT_THREAD_MAXPROGRESS, 0, TextLength);
+ RegExpr.State := [preNotEmpty];
+ // search for regular expression
+ if not RegExpr.Match then
+ begin
+ s := TranslateWideString('No messages in this file');
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ end
+ else
+ begin
+ PosCur := RegExpr.MatchedExpressionOffset;
+ // get the position of RegExpression
+ repeat
+ LenCur := RegExpr.MatchedExpressionLength;
+ // get the length of RegExpression
+ // Further we define a message direction (incoming or outgoing)
+ if RegExpr.SubExpressions[WorkPattern.Msg.Direction] = WorkPattern.Msg.Incoming then
+ msg_flag := DBEF_READ
+ else
+ msg_flag := DBEF_READ or DBEF_SENT;
+ msg_flag := msg_flag or DBEF_UTF;
+ // make timestamp
+ if WorkPattern.Msg.Seconds <> 0 then
+ DT := timestamp
+ (StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Year]),
+ StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Month]),
+ StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Day]),
+ StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Hours]),
+ StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Minutes]),
+ StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Seconds]))
else
- begin
- s:=TranslateWideString('Can''t determine destination contact');
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
- end;
+ DT := timestamp
+ (StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Year]),
+ StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Month]),
+ StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Day]),
+ StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Hours]),
+ StrToInt(RegExpr.SubExpressions[WorkPattern.Msg.Minutes]), 0);
+
+ if RegExpr.MatchAgain then
+ PosNext := RegExpr.MatchedExpressionOffset
+ // search for next regexpr
+ else
+ PosNext := TextLength; // if not then end of file
+ h1 := PosCur + LenCur; // The message text beginning presumably
+ h2 := PosNext - PosCur - LenCur - 2; // its presumably message length
+ // working with message text
+ if WorkPattern.UsePreMsg then
+ PRN := DWORD(WorkPattern.PreMsg.PreRN)
+ else
+ PRN := DWORD(-1);
+ if PRN <> 0 then
+ begin
+ j := 1;
+ while ((RegExpr.Subject[h1] = Char($0D)) and
+ (RegExpr.Subject[h1 + 1] = Char($0A))) and (j <= PRN) do
+ begin
+ inc(h1, 2);
+ Dec(h2, 2);
+ inc(j);
+ end; // remove carriage return in the beginning
+ end;
+ if WorkPattern.UsePreMsg then
+ ARN := DWORD(WorkPattern.PreMsg.AfterRN)
+ else
+ ARN := DWORD(-1);
+ if ARN <> 0 then
+ begin
+ j := 1;
+ while ((RegExpr.Subject[h1 + h2] = Char($0D)) and
+ (RegExpr.Subject[h1 + h2 + 1] = Char($0A))) and (j <= ARN) do
+ begin
+ Dec(h2, 2);
+ inc(j)
+ end; // remove carriage return in the end
+ end;
+ // get the message text
+ TxtMsg := Copy(RegExpr.Subject, h1, h2 + 2);
+ // remove spaces if needs
+ if WorkPattern.UsePreMsg and
+ ((WorkPattern.PreMsg.PreSP <> 0) or
+ (WorkPattern.PreMsg.AfterSP <> 0)) then
+ PreMessageSP(TxtMsg, UTF8Len(PAnsiChar(RegExpr.MatchedExpression)));
+ AddMsgToDB(DContact.hContact, msg_flag, DT, TxtMsg, AddedMessages,
+ Duplicates); // adding in base
+ PosCur := PosNext;
+ DoMessage(ITXT_THREAD_PROGRESS, PosCur, 0);
+ until (PosNext = TextLength) or Terminated;
+ end; // RegExpr.Exec
+ end
+ else
+ begin
+ s := TranslateWideString('Can''t determine destination contact');
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ end;
end;
procedure TImportThrd.BinImportProcedure;
-var i:integer;
- s:WideString;
- tempstr:PChar;
-var dbei:TDBEVENTINFO;
- proto:string;
- pt:integer;
- fsz:integer;
-
-{$define BIN_IMPORT_}
-{$i BmContactIP.inc}
-{$i BqhfIP.inc}
-{$i BICQ6IP.inc}
-{$i BICQ5IP.inc}
-{$i BRMSIP.inc}
-{$i BbayanIP.inc}
-{$undef BIN_IMPORT_}
+var
+ i: integer;
+ s: WideString;
+ tempstr: PAnsiChar;
+var
+ dbei: TDBEVENTINFO;
+ proto: AnsiString;
+ pt: int_ptr;
+ fsz: cardinal;
+{$DEFINE BIN_IMPORT_}
+{$I BmContactIP.inc}
+{$I BqhfIP.inc}
+{$I BICQ6IP.inc}
+{$I BICQ5IP.inc}
+{$I BRMSIP.inc}
+{$I BbayanIP.inc}
+{$UNDEF BIN_IMPORT_}
begin
- AddedMessages:=0;
- Duplicates:=0;
- case WorkPattern.BinProc of
- 1: //mContactImport
- {$i BmContactIP.inc}
- 2: //QHF
- {$i BqhfIP.inc}
- 3: //ICQ6
- {$i BICQ6IP.inc}
- 4: //ICQ5
- {$i BICQ5IP.inc}
- 5: //Nokia midp-rms
- {$i BRMSIP.inc}
- 6: //BayanICQ
- {$i BbayanIP.inc}
-
- end;
+ AddedMessages := 0;
+ Duplicates := 0;
+ case WorkPattern.BinProc of
+ 1: // mContactImport
+ {$I BmContactIP.inc}
+ 2: // QHF
+ {$I BqhfIP.inc}
+ 3: // ICQ6
+ {$I BICQ6IP.inc}
+ 4: // ICQ5
+ {$I BICQ5IP.inc}
+ 5: // Nokia midp-rms
+ {$I BRMSIP.inc}
+ 6: // BayanICQ
+ {$I BbayanIP.inc}
+ end;
end;
procedure TImportThrd.Execute;
var
- i:integer;
- s1:WideString;
- tempstr:PChar;
+ i: integer;
+ s1: WideString;
+ tempstr: PAnsiChar;
begin
- DoMessage(ITXT_THREAD_ALLSTARTED,0,0);
- FolderName:=Copy(FileNames,1,OffsetFileName-1);
- i:=OffsetFileName;
- while (FileNames[i+1]<>#0)and not Terminated do
- begin //начало цикла по файлам
- s1:='';
- Inc(i);
- while FileNames[i]<>#0 do
- begin s1:=s1+FileNames[i]; inc(i); end;
- if (s1<>'') and (s1<>#0) then
- begin //Начинаем работать с файлом
- FileName:=FolderName+'\'+s1;
- DoMessage(ITXT_THREAD_START_FILE,Integer(PWideChar(FileName)),0,smSend);
- pFileText:=nil;
- hFile:=INVALID_HANDLE_VALUE;
- DContact.ProtoName:=Destination.ProtoName;
- fContact.hContact:=INVALID_HANDLE_VALUE;
- RegExpr:=TPerlRegEx.Create; //Создаём объект для работы с рег. выражениями
- try
- //Поработаем с именем файла
- if WorkPattern.UseFileName then
- if (DContact.hContact=0) or (DContact.hContact=INVALID_HANDLE_VALUE) then
+ DoMessage(ITXT_THREAD_ALLSTARTED, 0, 0);
+ FolderName := Copy(FileNames, 1, OffsetFileName - 1);
+ i := OffsetFileName;
+ while (FileNames[i + 1] <> #0) and not Terminated do
+ begin // начало цикла по файлам
+ s1 := '';
+ inc(i);
+ while FileNames[i] <> #0 do
begin
- if IsMirandaUnicode then
- begin
- tempstr:=WideToUTF8(PWideChar(FileName),tempstr);
- RegExpr.Subject:=tempstr;
- FreeMem(tempstr);
- tempstr:=ANSIToUTF8(PAnsiChar(WorkPattern.FName.Pattern),tempstr,cp);
- RegExpr.RegEx:=tempstr;
- FreeMem(tempstr);
- RegExpr.Options:=[preUTF8];
- end
- else
- begin
- RegExpr.Subject:=FileName;
- RegExpr.RegEx:=WorkPattern.FName.Pattern;
- RegExpr.Options:=[];
- end;
- if RegExpr.Match then
- begin
- fContact.ProtoName:=Destination.ProtoName;
- if WorkPattern.FName.InUID<>0 then fContact.ContactUID:=RegExpr.SubExpressions[WorkPattern.FName.InUID]
- else fContact.ContactUID:='';
- if WorkPattern.FName.InNick<>0 then fContact.ContactNick:=RegExpr.SubExpressions[WorkPattern.FName.InNick]
- else fContact.ContactNick:='';
- TryDetermContact(fContact);
+ s1 := s1 + FileNames[i];
+ inc(i);
+ end;
+ if (s1 <> '') and (s1 <> #0) then
+ begin // Начинаем работать с файлом
+ FileName := FolderName + '\' + s1;
+ DoMessage(ITXT_THREAD_START_FILE, wparam(PWideChar(FileName)),0, smSend);
+ pFileText := nil;
+ hFile := INVALID_HANDLE_VALUE;
+ DContact.ProtoName := Destination.ProtoName;
+ fContact.hContact := INVALID_HANDLE_VALUE;
+ RegExpr := TPerlRegEx.Create;
+ // Создаём объект для работы с рег. выражениями
+ try
+ // Поработаем с именем файла
+ if WorkPattern.UseFileName then
+ if (DContact.hContact = 0) or
+ (DContact.hContact = INVALID_HANDLE_VALUE) then
+ begin
+ tempstr := WidetoUTF8(PWideChar(FileName), tempstr);
+ RegExpr.Subject := tempstr;
+ FreeMem(tempstr);
+ tempstr := ANSIToUTF8(PAnsiChar(WorkPattern.FName.Pattern),tempstr, cp);
+ RegExpr.RegEx := tempstr;
+ FreeMem(tempstr);
+ RegExpr.Options := [preUTF8];
+
+ if RegExpr.Match then
+ begin
+ fContact.ProtoName := Destination.ProtoName;
+ if WorkPattern.FName.InUID <> 0 then
+ fContact.ContactUID := RegExpr.SubExpressions[WorkPattern.FName.InUID]
+ else
+ fContact.ContactUID := '';
+ if WorkPattern.FName.InNick <> 0 then
+ fContact.ContactNick := RegExpr.SubExpressions[WorkPattern.FName.InNick]
+ else
+ fContact.ContactNick := '';
+ TryDetermContact(fContact);
+ end;
+ end;
+
+ // Загружаем сам файл
+ // [preMultiLine] модификатор для восприятия многострочного текста
+ if DoMapFile then // Загружаем файл
+ begin
+ CallService(MS_DB_SETSAFETYMODE, wParam(FALSE), 0);
+ case WorkPattern.IType of
+ 1: TextImportProcedure;
+ 2: BinImportProcedure;
+ end; // case
+ end; // DoMapFile
+ finally
+ CallService(MS_DB_SETSAFETYMODE, wParam(true), 0);
+ DoMessage(ITXT_THREAD_FINISH, AddedMessages, Duplicates);
+ DoUnMapFile;
+ RegExpr.Free;
end;
- end;
-
- //Загружаем сам файл
- // [preMultiLine] модификатор для восприятия многострочного текста
- if DoMapFile then //Загружаем файл
- begin
- pluginLink^.CallService(MS_DB_SETSAFETYMODE, wParam(false), 0);
- case WorkPattern.IType of
- 1:TextImportProcedure;
- 2:BinImportProcedure;
- end; //case
- end; //DoMapFile
- finally
- pluginLink^.CallService(MS_DB_SETSAFETYMODE, wParam(true), 0);
- DoMessage(ITXT_THREAD_FINISH,AddedMessages,Duplicates);
- DoUnMapFile;
- RegExpr.Free;
- end;
- DContact.hContact:=INVALID_HANDLE_VALUE;
- Sleep(10); //чтобы все сообщения дошли до окна
- end; //закончили работать с файлом
- end; //цикла по файлам
- DoMessage(ITXT_THREAD_ALLFINISHED,0,0);
+ DContact.hContact := INVALID_HANDLE_VALUE;
+ Sleep(10); // чтобы все сообщения дошли до окна
+ end; // закончили работать с файлом
+ end; // цикла по файлам
+ DoMessage(ITXT_THREAD_ALLFINISHED, 0, 0);
end;
end.
- \ No newline at end of file
diff --git a/plugins/ImportTXT/ImportTxtWiz.pas b/plugins/ImportTXT/ImportTxtWiz.pas
index 72c74b2386..25b5896892 100644
--- a/plugins/ImportTXT/ImportTxtWiz.pas
+++ b/plugins/ImportTXT/ImportTxtWiz.pas
@@ -2,368 +2,389 @@ unit ImportTxtWiz;
interface
-uses Windows,Messages,SysUtils,
- m_api,
- general, ImportTU, FileDlgs,
- ImportThrd
- ;
+uses Windows, Messages, SysUtils,
+ m_api,
+ general, ImportTU, FileDlgs,
+ ImportThrd;
{$R ImpTxtWiz.res}
{$I ImpWizRes.inc}
-const
- WIZM_GOTOPAGE = (WM_USER+10); //wParam=resource id, lParam=dlgproc
- WIZM_DISABLEBUTTON = (WM_USER+11); //wParam=0:back, 1:next, 2:cancel
- WIZM_SETCANCELTEXT = (WM_USER+12); //lParam=(char*)newText
- WIZM_SETNEXTTEXT = (WM_USER+13); //lParam=(char*)newText
- WIZM_ENABLEBUTTON = (WM_USER+14); //wParam=0:back, 1:next, 2:cancel
-
- WIZM_ACCLISTCHANGED = (WM_USER+15); //OnAccountListChanged
-
-var hwndPage:HWND;
- IndexOfPattern:integer;
- FileNames:array of WideString;
- FileName:string;
- nFO:integer;
- FilePath:WideString;
- ProtoSelect: integer;
- ImportThrd:TImportThrd;
- StartTime,FinishTime:TDateTime;
-
-function WizardIntroPageProc(hdlg:HWND; hMessage,wParam,lParam:DWORD):LongBool; stdcall;
-function ImportTypePageProc(hdlg:HWND; hMessage,wParam,lParam:DWORD):LongBool; stdcall;
-function WizardDlgProc(hdlg:HWND; hMessage,wParam,lParam:DWORD):LongBool; stdcall;
-function ImportFilesPageProc(hdlg:HWND; hMessage,wParam,lParam:DWORD):LongBool; stdcall;
-function ImportDestinationPageProc(hdlg:HWND; hMessage,wParam,lParam:DWORD):LongBool; stdcall;
-function ImportProgressPageProc(hdlg:HWND; hMessage,wParam,lParam:DWORD):LongBool; stdcall;
+function WizardIntroPageProc(hdlg: HWND; hMessage:uint; wParam:WPARAM; lParam:LPARAM): LongBool; stdcall;
+function ImportTypePageProc(hdlg: HWND; hMessage:uint; wParam:WPARAM; lParam:LPARAM): LongBool; stdcall;
+function WizardDlgProc(hdlg: HWND; hMessage:uint; wParam:WPARAM; lParam:LPARAM): LongBool; stdcall;
+function ImportFilesPageProc(hdlg: HWND; hMessage:uint; wParam:WPARAM; lParam:LPARAM): LongBool; stdcall;
+function ImportDestinationPageProc(hdlg: HWND; hMessage:uint; wParam:WPARAM; lParam:LPARAM): LongBool; stdcall;
+function ImportProgressPageProc(hdlg: HWND; hMessage:uint; wParam:WPARAM; lParam:LPARAM): LongBool; stdcall;
implementation
+const
+ WIZM_GOTOPAGE = (WM_USER + 10); // wParam=resource id, lParam=dlgproc
+ WIZM_DISABLEBUTTON = (WM_USER + 11); // wParam=0:back, 1:next, 2:cancel
+ WIZM_SETCANCELTEXT = (WM_USER + 12); // lParam=(char*)newText
+ WIZM_SETNEXTTEXT = (WM_USER + 13); // lParam=(char*)newText
+ WIZM_ENABLEBUTTON = (WM_USER + 14); // wParam=0:back, 1:next, 2:cancel
+ WIZM_ACCLISTCHANGED = (WM_USER + 15); // OnAccountListChanged
-function MakeFileList(hdlg:HWND; param:WORD):boolean;
-var i:integer;
- s1:WideString;
+var
+ hwndPage: HWND;
+ IndexOfPattern: integer;
+ ImportThrd: TImportThrd;
+ ProtoSelect: integer;
+ nFO: integer;
+ FilePath: WideString;
+ FileName: WideString;
+ FileNames: array of WideString;
+ StartTime, FinishTime: TDateTime;
+
+function MakeFileList(hdlg: HWND; param: WORD): boolean;
+var
+ i: integer;
+ s1: WideString;
begin
- result:=false;
- case param of
- IDC_FILE: FileName:=OpenDialogExecute(hdlg, $0200, nFO,TxtPatterns[IndexOfPattern].DefExtension); //OFN_ALLOWMULTISELECT = $00000200;
- IDC_DIR: FileName:=FolderDialogExecute(hdlg, nFO,TxtPatterns[IndexOfPattern].DefExtension);
- end;
- if FileName<>'' then
+ result := false;
+ case param of
+ IDC_FILE:
+ FileName := OpenDialogExecute(hdlg, $0200, nFO, TxtPatterns[IndexOfPattern].DefExtension);
+ // OFN_ALLOWMULTISELECT = $00000200;
+ IDC_DIR:
+ FileName := FolderDialogExecute(hdlg, nFO, TxtPatterns[IndexOfPattern].DefExtension);
+ end;
+ if FileName <> '' then
begin
- SendDlgItemMessageW(hDlg,IDC_LIST,LB_RESETCONTENT,0,0);
- SendDlgItemMessageW(hdlg, IDC_PATH,WM_SETTEXT,0,0);
- SetLength(FileNames,0);
- FilePath:=Copy(FileName,1,nFO-1);
- SendDlgItemMessageW(hdlg, IDC_PATH,WM_SETTEXT,0,dword(PWideChar(FilePath)));
- i:=nFO;
- while FileName[i+1]<>#0 do
+ SendDlgItemMessageW(hdlg, IDC_LIST, LB_RESETCONTENT, 0, 0);
+ SendDlgItemMessageW(hdlg, IDC_PATH, WM_SETTEXT, 0, 0);
+ SetLength(FileNames, 0);
+ FilePath := Copy(FileName, 1, nFO - 1);
+ SendDlgItemMessageW(hdlg, IDC_PATH, WM_SETTEXT, 0, lparam(PWideChar(FilePath)));
+ i := nFO;
+ while FileName[i + 1] <> #0 do
begin
- s1:='';
- Inc(i);
- while FileName[i]<>#0 do
- begin s1:=s1+FileName[i]; inc(i); end;
- if (s1<>'') and (s1<>#0) then
+ s1 := '';
+ Inc(i);
+ while FileName[i] <> #0 do
begin
- SetLength(FileNames,Length(FileNames)+1);
- FileNames[High(FileNames)]:=s1;
- SendDlgItemMessageW(hDlg,IDC_LIST,LB_ADDSTRING,0,Integer(PWideChar(s1)));
- end;
+ s1 := s1 + FileName[i];
+ Inc(i);
+ end;
+ if (s1 <> '') and (s1 <> #0) then
+ begin
+ SetLength(FileNames, Length(FileNames) + 1);
+ FileNames[High(FileNames)] := s1;
+ SendDlgItemMessageW(hdlg, IDC_LIST, LB_ADDSTRING, 0, lparam(PWideChar(s1)));
+ end;
end;
end;
- if High(FileNames)>-1 then result:=true;
+ if High(FileNames) > -1 then
+ result := true;
end;
-procedure AddStatusMessage(hDLG:HWND; msg:WideString);
+procedure AddStatusMessage(hdlg: HWND; msg: WideString);
begin
- SendDlgItemMessageW(hDLG,IDC_STATUS,LB_SETCURSEL,SendDlgItemMessageW(hDLG,IDC_STATUS,LB_ADDSTRING,0,dword(PWideChar(msg))),0);
+ SendDlgItemMessageW(hdlg, IDC_STATUS, LB_SETCURSEL,
+ SendDlgItemMessageW(hdlg, IDC_STATUS, LB_ADDSTRING, 0, lparam(PWideChar(msg))), 0);
end;
procedure AccLstChngd;
begin
- SendMessageW(hwndPage,WIZM_ACCLISTCHANGED,0,0);
+ SendMessageW(hwndPage, WIZM_ACCLISTCHANGED, 0, 0);
end;
-function WizardIntroPageProc(hdlg:HWND; hMessage,wParam,lParam:DWORD):LongBool; stdcall;
+function WizardIntroPageProc(hdlg: HWND; hMessage:uint; wParam:WPARAM; lParam:LPARAM): LongBool; stdcall;
begin
- result:=false;
- case hMessage of
- WM_INITDIALOG:
- begin
- TranslateDialogDefault(hdlg);
- SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 0, 0);
- IndexOfPattern:=0;
- ProtoSelect:=0;
- SetLength(FileNames,0);
- result:=true;
- end;
- WM_COMMAND:
- case LOWORD(wParam) of
- IDOK:
- PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_IMPTYPE, integer(@ImportTypePageProc));
- IDCANCEL:
- PostMessage(GetParent(hdlg), WM_CLOSE, 0, 0);
- end; //Case wParam
- end; //Case hMassege
+ result := false;
+ case hMessage of
+ WM_INITDIALOG:
+ begin
+ TranslateDialogDefault(hdlg);
+ SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 0, 0);
+ IndexOfPattern := 0;
+ ProtoSelect := 0;
+ SetLength(FileNames, 0);
+ result := true;
+ end;
+ WM_COMMAND:
+ case LOWORD(wParam) of
+ IDOK:
+ PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_IMPTYPE, tlparam(@ImportTypePageProc));
+ IDCANCEL:
+ PostMessage(GetParent(hdlg), WM_CLOSE, 0, 0);
+ end; // Case wParam
+ end; // Case hMassege
end;
-function ImportTypePageProc(hdlg:HWND; hMessage,wParam,lParam:DWORD):LongBool; stdcall;
-var i:integer;
+function ImportTypePageProc(hdlg: HWND; hMessage:uint; wParam:WPARAM; lParam:LPARAM): LongBool; stdcall;
+var
+ i: integer;
begin
- result:=false;
- case hMessage of
- WM_INITDIALOG:
- begin
- TranslateDialogDefault(hdlg);
- ReadPatterns;
- if PatternsCount>0 then
+ result := false;
+ case hMessage of
+ WM_INITDIALOG:
begin
- For i:=0 to PatternsCount-1 do
- SendDlgItemMessage(hDlg,IDC_COMBO1,CB_ADDSTRING,0,Integer(PatternNames[i]));
- SendDlgItemMessage(hDlg, IDC_COMBO1, CB_SETCURSEL, GetLastPattern, 0);
- IndexOfPattern:=GetLastPattern;
- end
- else
- SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 1, 0);
- result:=true;
- end;
- WM_COMMAND:
- begin
- if (HiWord(wParam)=CBN_SELCHANGE) and (LoWord(wParam)=IDC_COMBO1) then
- IndexOfPattern:=SendDlgItemMessage(hdlg, IDC_COMBO1, CB_GETCURSEL, 0, 0);
- Case LOWORD(wParam) of
- IDC_BACK:
- PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_IMPWIZARDINTRO, integer(@WizardIntroPageProc));
- IDOK:
- PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_IMPFILES, integer(@ImportFilesPageProc));
- IDCANCEL:
- PostMessage(GetParent(hdlg), WM_CLOSE, 0, 0);
- end; //Case wParam
- end; //WM_COMMAND
- end; //Case hMassage
+ TranslateDialogDefault(hdlg);
+ ReadPatterns;
+ if Length(TxtPatterns) > 0 then
+ begin
+ For i := 0 to High(TxtPatterns) do
+ SendDlgItemMessage(hdlg, IDC_COMBO1, CB_ADDSTRING, 0, tlparam(PChar(TxtPatterns[i].Name)));
+ SendDlgItemMessage(hdlg, IDC_COMBO1, CB_SETCURSEL, GetLastPattern, 0);
+ IndexOfPattern := GetLastPattern;
+ end
+ else
+ SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 1, 0);
+ result := true;
+ end;
+ WM_COMMAND:
+ begin
+ if (HiWord(wParam) = CBN_SELCHANGE) and (LOWORD(wParam) = IDC_COMBO1)
+ then
+ IndexOfPattern := SendDlgItemMessage(hdlg, IDC_COMBO1,
+ CB_GETCURSEL, 0, 0);
+ Case LOWORD(wParam) of
+ IDC_BACK:
+ PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_IMPWIZARDINTRO, tlparam(@WizardIntroPageProc));
+ IDOK:
+ PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_IMPFILES, tlparam(@ImportFilesPageProc));
+ IDCANCEL:
+ PostMessage(GetParent(hdlg), WM_CLOSE, 0, 0);
+ end; // Case wParam
+ end; // WM_COMMAND
+ end; // Case hMassage
end;
-function ImportFilesPageProc(hdlg:HWND; hMessage,wParam,lParam:DWORD):LongBool; stdcall;
-var i:integer;
+function ImportFilesPageProc(hdlg: HWND; hMessage:uint; wParam:WPARAM; lParam:LPARAM): LongBool; stdcall;
+var
+ i: integer;
begin
- result:=false;
- case hMessage of
- WM_INITDIALOG:
- begin
- TranslateDialogDefault(hdlg);
- if High(FileNames)<0 then SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 1, 0)
- else
+ result := false;
+ case hMessage of
+ WM_INITDIALOG:
begin
- SendDlgItemMessageW(hdlg, IDC_PATH,WM_SETTEXT,0,dword(PWideChar(FilePath)));
- for i:=0 to High(FileNames) do
- SendDlgItemMessageW(hDlg,IDC_LIST,LB_ADDSTRING,0,Integer(PWideChar(FileNames[i])));
+ TranslateDialogDefault(hdlg);
+ if High(FileNames) < 0 then
+ SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 1, 0)
+ else
+ begin
+ SendDlgItemMessageW(hdlg, IDC_PATH, WM_SETTEXT, 0, tlparam(PWideChar(FilePath)));
+ for i := 0 to High(FileNames) do
+ SendDlgItemMessageW(hdlg, IDC_LIST, LB_ADDSTRING, 0, tlparam(PWideChar(FileNames[i])));
+ end;
+ result := true;
end;
- result:=true;
- end;
- WM_COMMAND:
- Case LOWORD(wParam) of
- IDC_FILE,
- IDC_DIR: if MakeFileList(hdlg,LOWORD(wParam)) then SendMessage(GetParent(hdlg), WIZM_ENABLEBUTTON, 1, 0)
- else SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 1, 0);
- IDC_BACK:
- PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_IMPTYPE, integer(@ImportTypePageProc));
- IDOK:
- PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_IMPDEST, integer(@ImportDestinationPageProc));
- IDCANCEL:
- PostMessage(GetParent(hdlg), WM_CLOSE, 0, 0);
- end; //Case wParam
- end; //Case hMassage
+ WM_COMMAND:
+ Case LOWORD(wParam) of
+ IDC_FILE, IDC_DIR:
+ if MakeFileList(hdlg, LOWORD(wParam)) then
+ SendMessage(GetParent(hdlg), WIZM_ENABLEBUTTON, 1, 0)
+ else
+ SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 1, 0);
+ IDC_BACK:
+ PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_IMPTYPE, tlparam(@ImportTypePageProc));
+ IDOK:
+ PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_IMPDEST, tlparam(@ImportDestinationPageProc));
+ IDCANCEL:
+ PostMessage(GetParent(hdlg), WM_CLOSE, 0, 0);
+ end; // Case wParam
+ end; // Case hMassage
end;
-function ImportDestinationPageProc(hdlg:HWND; hMessage,wParam,lParam:DWORD):LongBool; stdcall;
-var i:integer;
- tempws:WideString;
+function ImportDestinationPageProc(hdlg: HWND; hMessage:uint; wParam:WPARAM; lParam:LPARAM): LongBool; stdcall;
+var
+ i: integer;
+ tempws: WideString;
begin
- result:=false;
- case hMessage of
- WM_INITDIALOG:
- begin
- TranslateDialogDefault(hdlg);
- EnumProtocols;
- for i:=0 to ProtoCount-1 do
- begin
- tempws:=Protocols[i].ProtoName+' | ';
- if IsMirandaUnicode then tempws:=tempws+UTF8Decode(Protocols[i].ProtoUID)+' | '+UTF8Decode(Protocols[i].ProtoNick)
- else tempws:=tempws+Protocols[i].ProtoUID+' | '+Protocols[i].ProtoNick;
- SendDlgItemMessageW(hDlg,IDC_COMBO1,CB_ADDSTRING,0,Integer(PWideChar(tempws)));
- end;
- SendDlgItemMessage(hDlg, IDC_COMBO1, CB_SETCURSEL, 0, 0);
- OnAccountListChange:=AccLstChngd;
- CheckDlgButton(hdlg,IDC_CHKDUPW,BST_CHECKED);
- CheckForDuplicates:=true;
- CheckDlgButton(hdlg,IDC_SHOWDUPW,BST_UNCHECKED);
- CheckForDuplicates:=false;
- result:=true;
- end;
- WM_COMMAND: begin
- if (HiWord(wParam)=CBN_SELCHANGE) and (LoWord(wParam)=IDC_COMBO1) then
- ProtoSelect:=SendDlgItemMessage(hdlg, IDC_COMBO1, CB_GETCURSEL, 0, 0);
- if (HiWord(wParam)=BN_CLICKED) and (LoWord(wParam)=IDC_CHKDUPW) then
- if LongBool(IsDlgButtonChecked(hdlg,IDC_CHKDUPW)) then EnableWindow(GetDlgItem(hdlg, IDC_SHOWDUPW), TRUE)
- else EnableWindow(GetDlgItem(hdlg, IDC_SHOWDUPW), FALSE);
- Case LOWORD(wParam) of
- IDC_BACK:
- PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_IMPFILES, integer(@ImportFilesPageProc));
- IDOK:begin
- CheckForDuplicates:=LongBool(IsDlgButtonChecked(hdlg,IDC_CHKDUPW));
- ShowDuplicates:=LongBool(IsDlgButtonChecked(hdlg,IDC_SHOWDUPW));
- PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_PROGRESS, integer(@ImportProgressPageProc));end;
- IDCANCEL:
- PostMessage(GetParent(hdlg), WM_CLOSE, 0, 0);
- end; //Case wParam
- end; //WM_COMMAND
- WIZM_ACCLISTCHANGED:begin
- ProtoSelect:=SendDlgItemMessage(hdlg, IDC_COMBO1, CB_GETCURSEL, 0, 0);
- SendDlgItemMessageW(hDlg,IDC_COMBO1,CB_RESETCONTENT,0,0);
- for i:=0 to ProtoCount-1 do
- begin
- tempws:=Protocols[i].ProtoName+' | ';
- if IsMirandaUnicode then tempws:=tempws+UTF8Decode(Protocols[i].ProtoUID)+' | '+UTF8Decode(Protocols[i].ProtoNick)
- else tempws:=tempws+Protocols[i].ProtoUID+' | '+Protocols[i].ProtoNick;
- SendDlgItemMessageW(hDlg,IDC_COMBO1,CB_ADDSTRING,0,Integer(PWideChar(tempws)));
- end;
- if ProtoSelect<ProtoCount-1 then SendDlgItemMessage(hDlg, IDC_COMBO1, CB_SETCURSEL, ProtoSelect, 0)
- else SendDlgItemMessage(hDlg, IDC_COMBO1, CB_SETCURSEL, ProtoCount-1, 0);
- end; //WIZM_...
- end; //Case hMassage
+ result := false;
+ case hMessage of
+ WM_INITDIALOG:
+ begin
+ TranslateDialogDefault(hdlg);
+ EnumProtocols;
+ for i := 0 to ProtoCount - 1 do
+ begin
+ tempws := Protocols[i].ProtoName + ' | ';
+ tempws := tempws + Protocols[i].ProtoUID + ' | ' + Protocols[i].ProtoNick;
+ SendDlgItemMessageW(hdlg, IDC_COMBO1, CB_ADDSTRING, 0, tlparam(PWideChar(tempws)));
+ end;
+ SendDlgItemMessage(hdlg, IDC_COMBO1, CB_SETCURSEL, 0, 0);
+ OnAccountListChange := AccLstChngd;
+ CheckDlgButton(hdlg, IDC_CHKDUPW, BST_CHECKED);
+ CheckForDuplicates := true;
+ CheckDlgButton(hdlg, IDC_SHOWDUPW, BST_UNCHECKED);
+ CheckForDuplicates := false;
+ result := true;
+ end;
+ WM_COMMAND:
+ begin
+ if (HiWord(wParam) = CBN_SELCHANGE) and (LOWORD(wParam) = IDC_COMBO1)
+ then
+ ProtoSelect := SendDlgItemMessage(hdlg, IDC_COMBO1, CB_GETCURSEL, 0, 0);
+
+ if (HiWord(wParam) = BN_CLICKED) and (LOWORD(wParam) = IDC_CHKDUPW) then
+ EnableWindow(GetDlgItem(hdlg, IDC_SHOWDUPW),
+ IsDlgButtonChecked(hdlg, IDC_CHKDUPW)<>BST_UNCHECKED);
+
+ Case LOWORD(wParam) of
+ IDC_BACK:
+ PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_IMPFILES, tlparam(@ImportFilesPageProc));
+ IDOK:
+ begin
+ CheckForDuplicates := LongBool(IsDlgButtonChecked(hdlg, IDC_CHKDUPW));
+ ShowDuplicates := LongBool(IsDlgButtonChecked(hdlg, IDC_SHOWDUPW));
+ PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_PROGRESS, tlparam(@ImportProgressPageProc));
+ end;
+ IDCANCEL:
+ PostMessage(GetParent(hdlg), WM_CLOSE, 0, 0);
+ end; // Case wParam
+ end; // WM_COMMAND
+ WIZM_ACCLISTCHANGED:
+ begin
+ ProtoSelect := SendDlgItemMessage(hdlg, IDC_COMBO1, CB_GETCURSEL, 0, 0);
+ SendDlgItemMessageW(hdlg, IDC_COMBO1, CB_RESETCONTENT, 0, 0);
+ for i := 0 to ProtoCount - 1 do
+ begin
+ tempws := Protocols[i].ProtoName + ' | ';
+ tempws := tempws + Protocols[i].ProtoUID + ' | ' + Protocols[i].ProtoNick;
+ SendDlgItemMessageW(hdlg, IDC_COMBO1, CB_ADDSTRING, 0, tlparam(PWideChar(tempws)));
+ end;
+ if ProtoSelect < ProtoCount - 1 then
+ SendDlgItemMessage(hdlg, IDC_COMBO1, CB_SETCURSEL, ProtoSelect, 0)
+ else
+ SendDlgItemMessage(hdlg, IDC_COMBO1, CB_SETCURSEL, ProtoCount - 1, 0);
+ end; // WIZM_...
+ end; // Case hMassage
end;
-function ImportProgressPageProc(hdlg:HWND; hMessage,wParam,lParam:DWORD):LongBool; stdcall;
-var H,Mi,sec,ms:word;
- s:WideString;
- tempwstr:PWideChar;
+function ImportProgressPageProc(hdlg: HWND; hMessage:uint; wParam:WPARAM; lParam:LPARAM): LongBool; stdcall;
+var
+ H, Mi, sec, ms: WORD;
+ s: WideString;
begin
- result:=false;
- case hMessage of
- WM_INITDIALOG:
- begin
- TranslateDialogDefault(hdlg);
- SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 0, 0);
- SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 1, 0);
- SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 2, 0);
- SendMessage(GetParent(hdlg), WIZM_SETCANCELTEXT, 0, Integer(PWideChar(TranslateWideString('Finish'))));
- //START THREAD
- ImportThrd:=TImportThrd.Create(TRUE);
- ImportThrd.FreeOnTerminate:=true;
- ImportThrd.DContact.hContact:=0;
- ImportThrd.Destination:=Protocols[ProtoSelect];
- ImportThrd.FileNames:=FileName+#0+#0;
- ImportThrd.OffsetFileName:=nFO;
- ImportThrd.WorkPattern:=TxtPatterns[IndexOfPattern];
- ImportThrd.ParentHWND:=hdlg;
- ImportThrd.Resume;
- result:=true;
- end;
- WM_COMMAND:
- Case LOWORD(wParam) of
- IDCANCEL:
- PostMessage(GetParent(hdlg), WM_CLOSE, 0, 0);
- end; //Case wParam
- //Далее оброботка сообщений от потока импорта
- //Начали
- ITXT_THREAD_ALLSTARTED:StartTime:=Time;
- ITXT_THREAD_START:begin
- AddStatusMessage(hdlg,TranslateWideString('Import started...'));
- end;
- //Известна длинна файла выставляем диапазон прогрессбара
- ITXT_THREAD_MAXPROGRESS:
- SendDlgItemMessage(hdlg,IDC_PROGRESS,PBM_SETRANGE,0,MakeLParam(0,lParam));
- //Идет прогресс ...
- ITXT_THREAD_PROGRESS:
- SendDlgItemMessage(hdlg,IDC_PROGRESS,PBM_SETPOS,wParam,0);
- //Возникла ошибка
- ITXT_THREAD_ERROR:
- AddStatusMessage(hdlg,TranslateWideString(PWideChar(wParam)));
- //Закончили
- ITXT_THREAD_FINISH:begin
- AddStatusMessage(hdlg,WideFormat(TranslateWideString('Added: %d messages'),[wParam]));
- AddStatusMessage(hdlg,WideFormat(TranslateWideString('Duplicates: %d messages'),[lParam]));
- end;
- //начали новый файл
- ITXT_THREAD_START_FILE:
- AddStatusMessage(hdlg,WideFormat(TranslateWideString('File: %s'),[PWideChar(wParam)]));
- //определили контакт
- ITXT_THREAD_DEST_CONTACT:begin
- if IsMirandaUnicode then
- begin
- tempwstr:=UTF8toWide(PChar(GetContactID(wParam,'',true)),tempwstr);
- s:= tempwstr;
- tempwstr:=UTF8toWide(PChar(GetContactNick(wParam,'',true)),tempwstr);
- s:=s + ' | ' + tempwstr;
- end
- else
- s:=GetContactID(wParam,'',true)+' | '+GetContactNick(wParam,'',true);
- AddStatusMessage(hdlg,WideFormat(TranslateWideString('To: %s'),[s]));
- end;
- ITXT_THREAD_ALLFINISHED:begin
- FinishTime:=Time;
- DecodeTime(FinishTime-StartTime,h,mi,sec,ms);
- AddStatusMessage(hdlg,WideFormat(TranslateWideString('In: %d:%d:%d'),[h,mi,sec]));
- SendMessage(GetParent(hdlg), WIZM_ENABLEBUTTON, 2, 0);
- end;
- end; //Case hMessage
+ result := false;
+ case hMessage of
+ WM_INITDIALOG:
+ begin
+ TranslateDialogDefault(hdlg);
+ SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 0, 0);
+ SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 1, 0);
+ SendMessage(GetParent(hdlg), WIZM_DISABLEBUTTON, 2, 0);
+ SendMessage(GetParent(hdlg), WIZM_SETCANCELTEXT, 0, tlparam(TranslateW('Finish')));
+ // START THREAD
+ ImportThrd := TImportThrd.Create(true);
+ ImportThrd.FreeOnTerminate := true;
+ ImportThrd.DContact.hContact := 0;
+ ImportThrd.Destination := Protocols[ProtoSelect];
+ ImportThrd.FileNames := FileName + #0 + #0;
+ ImportThrd.OffsetFileName := nFO;
+ ImportThrd.WorkPattern := TxtPatterns[IndexOfPattern];
+ ImportThrd.ParentHWND := hdlg;
+ ImportThrd.Resume;
+ result := true;
+ end;
+ WM_COMMAND:
+ Case LOWORD(wParam) of
+ IDCANCEL:
+ PostMessage(GetParent(hdlg), WM_CLOSE, 0, 0);
+ end; // Case wParam
+ // Далее оброботка сообщений от потока импорта
+ // Начали
+ ITXT_THREAD_ALLSTARTED:
+ StartTime := Time;
+ ITXT_THREAD_START:
+ begin
+ AddStatusMessage(hdlg, TranslateWideString('Import started...'));
+ end;
+ // Известна длинна файла выставляем диапазон прогрессбара
+ ITXT_THREAD_MAXPROGRESS:
+ SendDlgItemMessage(hdlg, IDC_PROGRESS, PBM_SETRANGE, 0, MakeLParam(0, lParam));
+ // Идет прогресс ...
+ ITXT_THREAD_PROGRESS:
+ SendDlgItemMessage(hdlg, IDC_PROGRESS, PBM_SETPOS, wParam, 0);
+ // Возникла ошибка
+ ITXT_THREAD_ERROR:
+ AddStatusMessage(hdlg, TranslateWideString(PWideChar(wParam)));
+ // Закончили
+ ITXT_THREAD_FINISH:
+ begin
+ AddStatusMessage(hdlg, WideFormat(TranslateWideString('Added: %d messages'), [wParam]));
+ AddStatusMessage(hdlg, WideFormat(TranslateWideString('Duplicates: %d messages'), [lParam]));
+ end;
+ // начали новый файл
+ ITXT_THREAD_START_FILE:
+ AddStatusMessage(hdlg, WideFormat(TranslateWideString('File: %s'), [PWideChar(wParam)]));
+ // определили контакт
+ ITXT_THREAD_DEST_CONTACT:
+ begin
+ s := GetContactID(wParam, '', true) + ' | ' + GetContactNick(wParam, '', true);
+ AddStatusMessage(hdlg, WideFormat(TranslateWideString('To: %s'), [s]));
+ end;
+ ITXT_THREAD_ALLFINISHED:
+ begin
+ FinishTime := Time;
+ DecodeTime(FinishTime - StartTime, H, Mi, sec, ms);
+ AddStatusMessage(hdlg, WideFormat(TranslateWideString('In: %d:%d:%d'), [H, Mi, sec]));
+ SendMessage(GetParent(hdlg), WIZM_ENABLEBUTTON, 2, 0);
+ end;
+ end; // Case hMessage
end;
-function WizardDlgProc(hdlg:HWND; hMessage,wParam,lParam:DWORD):LongBool; stdcall;
+function WizardDlgProc(hdlg: HWND; hMessage:uint; wParam:WPARAM; lParam:LPARAM): LongBool; stdcall;
begin
- result:=false;
- case hMessage of
- WM_DESTROY:
- SetLastPattern(IndexOfPattern);
- WM_INITDIALOG:
- begin
- TranslateDialogDefault(hdlg);
- hwndPage:=CreateDialog(hInstance, MAKEINTRESOURCE(IDD_IMPWIZARDINTRO), hdlg, @WizardIntroPageProc);
- SetWindowPos(hwndPage, 0, 0, 0, 0, 0, SWP_NOZORDER or SWP_NOSIZE);
- ShowWindow(hwndPage, SW_SHOW);
- ShowWindow(hdlg, SW_SHOW);
- SendMessage(hdlg, WM_SETICON, ICON_BIG, LoadIcon(hInstance,MAKEINTRESOURCE(110)));
- result:=true;
- end;
- WIZM_GOTOPAGE:
- begin
- DestroyWindow(hwndPage);
- EnableWindow(GetDlgItem(hdlg, IDC_BACK), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDOK), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDCANCEL), TRUE);
- SetDlgItemTextW(hdlg, IDCANCEL, PWideChar(TranslateWideString('Cancel')));
- hwndPage:=CreateDialog(hInstance, MAKEINTRESOURCE(wParam), hdlg, Pointer(lParam));
- SetWindowPos(hwndPage, 0, 0, 0, 0, 0, SWP_NOZORDER or SWP_NOSIZE);
- ShowWindow(hwndPage, SW_SHOW);
- end;
- WIZM_DISABLEBUTTON:
- begin
- case wParam of
- 0: EnableWindow(GetDlgItem(hdlg, IDC_BACK), FALSE);
- 1: EnableWindow(GetDlgItem(hdlg, IDOK), FALSE);
- 2: EnableWindow(GetDlgItem(hdlg, IDCANCEL), FALSE);
- end; //Case wParam
- end;
- WIZM_ENABLEBUTTON:
- begin
- case wParam of
- 0: EnableWindow(GetDlgItem(hdlg, IDC_BACK), TRUE);
- 1: EnableWindow(GetDlgItem(hdlg, IDOK), TRUE);
- 2: EnableWindow(GetDlgItem(hdlg, IDCANCEL), TRUE);
- end; //Case wParam
- end;
- WIZM_SETCANCELTEXT:
- SetDlgItemTextW(hdlg, IDCANCEL, PWideChar(lParam));
- WIZM_SETNEXTTEXT:
- SetDlgItemTextW(hdlg, IDOK, PWideChar(lParam));
- WM_COMMAND:
- SendMessage(hwndPage, WM_COMMAND, wParam, lParam);
- WM_CLOSE:
- begin
- OnAccountListChange:=nil;
- DestroyWindow(hwndPage);
- DestroyWindow(hdlg);
- end;
- end;// Case hMessage
+ result := false;
+ case hMessage of
+ WM_DESTROY:
+ SetLastPattern(IndexOfPattern);
+ WM_INITDIALOG:
+ begin
+ TranslateDialogDefault(hdlg);
+ hwndPage := CreateDialog(hInstance, MAKEINTRESOURCE(IDD_IMPWIZARDINTRO),
+ hdlg, @WizardIntroPageProc);
+ SetWindowPos(hwndPage, 0, 0, 0, 0, 0, SWP_NOZORDER or SWP_NOSIZE);
+ ShowWindow(hwndPage, SW_SHOW);
+ ShowWindow(hdlg, SW_SHOW);
+ SendMessage(hdlg, WM_SETICON, ICON_BIG, LoadIcon(hInstance, MAKEINTRESOURCE(110)));
+ result := true;
+ end;
+ WIZM_GOTOPAGE:
+ begin
+ DestroyWindow(hwndPage);
+ EnableWindow(GetDlgItem(hdlg, IDC_BACK), true);
+ EnableWindow(GetDlgItem(hdlg, IDOK), true);
+ EnableWindow(GetDlgItem(hdlg, IDCANCEL), true);
+ SetDlgItemTextW(hdlg, IDCANCEL, TranslateW('Cancel'));
+ hwndPage := CreateDialog(hInstance, MAKEINTRESOURCE(wParam), hdlg, Pointer(lParam));
+ SetWindowPos(hwndPage, 0, 0, 0, 0, 0, SWP_NOZORDER or SWP_NOSIZE);
+ ShowWindow(hwndPage, SW_SHOW);
+ end;
+ WIZM_DISABLEBUTTON:
+ begin
+ case wParam of
+ 0: EnableWindow(GetDlgItem(hdlg, IDC_BACK), false);
+ 1: EnableWindow(GetDlgItem(hdlg, IDOK), false);
+ 2: EnableWindow(GetDlgItem(hdlg, IDCANCEL), false);
+ end; // Case wParam
+ end;
+ WIZM_ENABLEBUTTON:
+ begin
+ case wParam of
+ 0: EnableWindow(GetDlgItem(hdlg, IDC_BACK), true);
+ 1: EnableWindow(GetDlgItem(hdlg, IDOK), true);
+ 2: EnableWindow(GetDlgItem(hdlg, IDCANCEL), true);
+ end; // Case wParam
+ end;
+ WIZM_SETCANCELTEXT:
+ SetDlgItemTextW(hdlg, IDCANCEL, PWideChar(lParam));
+ WIZM_SETNEXTTEXT:
+ SetDlgItemTextW(hdlg, IDOK, PWideChar(lParam));
+ WM_COMMAND:
+ SendMessage(hwndPage, WM_COMMAND, wParam, lParam);
+ WM_CLOSE:
+ begin
+ OnAccountListChange := nil;
+ DestroyWindow(hwndPage);
+ DestroyWindow(hdlg);
+ end;
+ end; // Case hMessage
end;
+
end.
diff --git a/plugins/ImportTXT/importtxt.dpr b/plugins/ImportTXT/importtxt.dpr
index c7a1ab303b..5fea1c6a2b 100644
--- a/plugins/ImportTXT/importtxt.dpr
+++ b/plugins/ImportTXT/importtxt.dpr
@@ -22,15 +22,25 @@
library importtxt;
uses
- m_api,
Windows,
- General,
- ImportTxtDlg,
- ImportTxtWiz;
+ Messages,
+ SysUtils,
+ Inifiles,
+ m_api,// in '.\inc\m_api.pas',
+{ используются в ImportThrd
+ KOL in '.\kol\kol.pas',
+ err in '.\kol\err.pas',
+ KOLedb in '.\kol\KOLEdb.pas',
+}
+ General in 'general.pas',
+ ImportT in 'ImportT.pas',
+ ImportTU in 'ImportTU.pas',
+ ImportThrd in 'ImportThrd.pas',
+ PerlRegEx in 'PerlRegEx.pas',
+ ImportTxtDlg in 'ImportTxtDlg.pas',
+ ImportTxtWiz in 'ImportTxtWiz.pas';
{$R imptxt_ver.res}
-{$include m_helpers.inc}
-
const
PluginInfo:TPLUGININFOEX=(
@@ -58,145 +68,128 @@ const
BetaChangelogURL = nil;
var
- PluginInterfaces:array [0..1] of MUUID;
hwndWizard:HWND;
hwndDialog:HWND;
//Services
- SrvITxt,SrvIWiz:Cardinal;
+ SrvITxt,SrvIWiz:THANDLE;
//hooks
- onLoadHook:Cardinal;
- onAccChangHook:Cardinal;
-
-function MirandaPluginInfo(mirandaVersion:DWORD):PPLUGININFOEX; cdecl;
-begin
- MirVers:=mirandaVersion;
- result:=@PluginInfo;
- //PluginInfo.cbSize:=SizeOf(TPLUGININFO);
-end;
+ onLoadHook:THANDLE;
+ onAccChangHook:THANDLE;
function MirandaPluginInfoEx(mirandaVersion:DWORD):PPLUGININFOEX; cdecl;
begin
- MirVers:=mirandaVersion;
- result:=@PluginInfo;
- //PluginInfo.cbSize:=SizeOf(TPLUGININFOEX);
+ result := @PluginInfo;
+ // PluginInfo.cbSize:=SizeOf(TPLUGININFOEX);
end;
-function ContactMenuCommand(wParam: WPARAM; lParam: LPARAM): Integer; cdecl;
+function ContactMenuCommand(wParam: wParam; lParam: lParam): int_ptr; cdecl;
begin
- Result := 0;
+ result := 0;
if IsWindow(hwndDialog) then
- begin
+ begin
SetForegroundWindow(hwndDialog);
- BringWindowToTop(hwndDialog);
- end
- else
- hwndDialog:=CreateDialogParamW(hInstance,MAKEINTRESOURCEW(IDD_IMPDIALOG),0,@IDMainWndProc, wParam);
+ BringWindowToTop(hwndDialog);
+ end
+ else
+ hwndDialog := CreateDialogParamW(hInstance, MAKEINTRESOURCEW(IDD_IMPDIALOG),
+ 0, @IDMainWndProc, wParam);
end;
-function MainMenuCommand(wParam: WPARAM; lParam: LPARAM): Integer; cdecl;
+function MainMenuCommand(wParam: wParam; lParam: lParam): int_ptr; cdecl;
begin
- Result:=0;
- if (IsWindow(hwndWizard)) then
- begin
- SetForegroundWindow(hwndWizard);
- BringWindowToTop(hwndWizard);
- end
- else
- hwndWizard:=CreateDialogW(hInstance, MAKEINTRESOURCEW(IDD_IMPWIZARD), 0, @WizardDlgProc);
+ result := 0;
+ if (IsWindow(hwndWizard)) then
+ begin
+ SetForegroundWindow(hwndWizard);
+ BringWindowToTop(hwndWizard);
+ end
+ else
+ hwndWizard := CreateDialogW(hInstance, MAKEINTRESOURCEW(IDD_IMPWIZARD), 0, @WizardDlgProc);
end;
-function OnAccountChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+function OnAccountChanged(wParam: wParam; lParam: lParam): int; cdecl;
begin
- Result:=0;
+ result := 0;
EnumProtocols;
- if Assigned(OnAccountListChange) then OnAccountListChange;
+ if Assigned(OnAccountListChange) then
+ OnAccountListChange;
end;
-function OnModulesLoaded(wParam:WPARAM;lParam:LPARAM):int;cdecl;
-var upd: TUpdate;
- buf:array [0..63] of char;
+function OnModulesLoaded(wParam: wParam; lParam: lParam): int; cdecl;
+var
+ upd: TUpdate;
+ buf: array [0 .. 63] of char;
begin
- PluginLink^.UnhookEvent(onloadhook);
- Result:=0;
- EnumProtocols;
- // Register in updater
- if Boolean(PluginLink.ServiceExists(MS_UPDATE_REGISTER)) then
+ UnhookEvent(onLoadHook);
+ result := 0;
+ EnumProtocols;
+ // Register in updater
+ if Boolean(ServiceExists(MS_UPDATE_REGISTER)) then
begin
- ZeroMemory(@upd,SizeOf(upd));
- upd.cpbVersion := SizeOf(upd);
- upd.szComponentName := PluginInfo.ShortName;;
- upd.pbVersion := CreateVersionStringPlugin(@pluginInfo,buf);
- upd.cpbVersion := lstrlen(upd.pbVersion);
- upd.szUpdateURL := UpdateURL;
- upd.szVersionURL := VersionURL;
- upd.pbVersionPrefix := VersionPrefix;
- upd.cpbVersionPrefix := Length(VersionPrefix);
- upd.szBetaUpdateURL := BetaUpdateURL;
- upd.szBetaVersionURL := BetaVersionURL;
- upd.pbBetaVersionPrefix := BetaVersionPrefix;
- upd.cpbBetaVersionPrefix := length(upd.pbBetaVersionPrefix);
- upd.szBetaChangelogURL := BetaChangelogURL;
- PluginLink.CallService(MS_UPDATE_REGISTER, 0, DWORD(@upd));
+ ZeroMemory(@upd, sizeof(upd));
+ upd.cpbVersion := sizeof(upd);
+ upd.szComponentName := PluginInfo.shortName;;
+ upd.pbVersion := CreateVersionStringPlugin(@PluginInfo, @buf);
+ upd.cpbVersion := lstrlena(upd.pbVersion);
+ upd.szUpdateURL := UpdateURL;
+ upd.szVersionURL := VersionURL;
+ upd.pbVersionPrefix := VersionPrefix;
+ upd.cpbVersionPrefix := Length(VersionPrefix);
+ upd.szBetaUpdateURL := BetaUpdateURL;
+ upd.szBetaVersionURL := BetaVersionURL;
+ upd.pbBetaVersionPrefix := BetaVersionPrefix;
+ upd.cpbBetaVersionPrefix := Length(upd.pbBetaVersionPrefix);
+ upd.szBetaChangelogURL := BetaChangelogURL;
+ CallService(MS_UPDATE_REGISTER, 0, tlparam(@upd));
+ end;
+ // check for AutoStart
+ if (DBReadByte(0, IMPORT_TXT_MODULE, IMPORT_TXT_AS) = 1) and (ProtoCount > 0) then
+ begin
+ CallService(IMPORT_WIZ_SERVICE, 0, 0);
+ DBWriteByte(0, IMPORT_TXT_MODULE, IMPORT_TXT_AS, 0);
end;
- //check for AutoStart
- if (DBReadByte(0,IMPORT_TXT_MODULE,IMPORT_TXT_AS)=1) and
- (ProtoCount>0) then
- begin
- pluginLink^.CallService(IMPORT_WIZ_SERVICE,0,0);
- DBWriteByte(0,IMPORT_TXT_MODULE,IMPORT_TXT_AS,0);
- end;
end;
-
-function Load(link: PPLUGINLINK): int; cdecl;
+function Load(): int; cdecl;
var
- mi: TCListMenuItem;
+ mi: TCListMenuItem;
begin
- PLUGINLINK := Pointer(link);
- IsMirandaUnicode:=fIsMirandaUnicode;
- cp:=pluginLink^.CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
- SrvITxt:=pluginLink^.CreateServiceFunction(IMPORT_TXT_SERVICE, @ContactMenuCommand);
- SrvIWiz:=pluginLink^.CreateServiceFunction(IMPORT_WIZ_SERVICE, @MainMenuCommand);
+ cp := CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
+ SrvITxt := CreateServiceFunction(IMPORT_TXT_SERVICE, @ContactMenuCommand);
+ SrvIWiz := CreateServiceFunction(IMPORT_WIZ_SERVICE, @MainMenuCommand);
FillChar(mi, sizeof(mi), 0);
mi.cbSize := sizeof(mi);
mi.flags := 0;
mi.position := 1000090050;
- mi.hIcon := LoadIcon(hInstance,MAKEINTRESOURCE(IDI_DEFAULT));
+ mi.hIcon := LoadIcon(hInstance, MAKEINTRESOURCE(IDI_DEFAULT));
mi.szName.a := 'Import history';
mi.pszService := IMPORT_TXT_SERVICE;
- mi.pszContactOwner:=nil; //All contacts
- pluginLink^.CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, int(@mi));
+ mi.pszContactOwner := nil; // All contacts
+ Menu_AddContacTMenuItem(@mi);
+
mi.position := 500050010;
mi.pszService := IMPORT_WIZ_SERVICE;
- mi.pszContactOwner:=nil;
- pluginLink^.CallService(MS_CLIST_ADDMAINMENUITEM, 0, int(@mi));
- onloadhook:=PluginLink^.HookEvent(ME_SYSTEM_MODULESLOADED,@OnModulesLoaded);
- if MirVers>080000 then onAccChangHook:=pluginLink^.HookEvent(ME_PROTO_ACCLISTCHANGED,@OnAccountChanged);
- Result := 0;
+ mi.pszContactOwner := nil;
+ Menu_AddMainMenuItem(@mi);
+
+ onLoadHook := HookEvent(ME_SYSTEM_MODULESLOADED, @OnModulesLoaded);
+ onAccChangHook := HookEvent(ME_PROTO_ACCLISTCHANGED, @OnAccountChanged);
+ result := 0;
end;
function Unload: int; cdecl;
begin
- if MirVers>080000 then pluginLink^.UnhookEvent(onAccChangHook);
- pluginlink^.DestroyServiceFunction(SrvITxt);
- pluginlink^.DestroyServiceFunction(SrvIWiz);
+ UnhookEvent(onAccChangHook);
+ DestroyServiceFunction(SrvITxt);
+ DestroyServiceFunction(SrvIWiz);
Result := 0;
end;
-function MirandaPluginInterfaces:PMUUID; cdecl;
-begin
- PluginInterfaces[0]:=PluginInfo.uuid;
- PluginInterfaces[1]:=MIID_LAST;
- result:=@PluginInterfaces;
-end;
-
exports
Load, Unload,
- MirandaPluginInfo,
- MirandaPluginInfoEx,
- MirandaPluginInterfaces;
+ MirandaPluginInfoEx;
begin
end.
diff --git a/plugins/ImportTXT/importtxtdlg.pas b/plugins/ImportTXT/importtxtdlg.pas
index 84f1c3a6cf..e4901d9d5a 100644
--- a/plugins/ImportTXT/importtxtdlg.pas
+++ b/plugins/ImportTXT/importtxtdlg.pas
@@ -10,224 +10,220 @@ uses
{$I ImpDlgRes.inc}
-
-function IDMainWndProc(Dialog:HWnd; hMessage,wParam,lParam:DWord):integer; stdcall;
-function GetContactDisplayName(hContact:THandle):string;
+function IDMainWndProc(Dialog:HWnd; hMessage:uint;wParam:WPARAM;lParam:LPARAM):lresult; stdcall;
implementation
{$R ImpTxtDlg.res}
-type TImpTxtDlgData = record
- cbSize:integer;
- CanStart:boolean;
- ChoFile:boolean;
- ChoPatt:boolean;
- PattFError:boolean;
- ITStarted:boolean;
- ITFinished:boolean;
- StartTime:TDateTime;
- FinishTime:TDateTime;
- IndexOfPattern:integer;
- oFN:integer;
- hContact:THandle;
- ImportThrd:TImportThrd;
- end;
+type
+ TImpTxtDlgData = record
+ cbSize: integer;
+ CanStart: boolean;
+ ChoFile: boolean;
+ ChoPatt: boolean;
+ PattFError: boolean;
+ ITStarted: boolean;
+ ITFinished: boolean;
+ StartTime: TDateTime;
+ FinishTime: TDateTime;
+ IndexOfPattern: integer;
+ oFN: integer;
+ hContact: THandle;
+ ImportThrd: TImportThrd;
+ end;
type PImpTxtDlgData = ^TImpTxtDlgData;
var ITDD:TImpTxtDlgData;
-function GetContactDisplayName(hContact:THandle):string;
-begin
- Result := PChar(pluginLink^.CallService(MS_CLIST_GETCONTACTDISPLAYNAME,hContact,0));
-end;
-
procedure AddStatusMessage(hDLG:HWND; msg:WideString);
begin
- SendDlgItemMessageW(hDLG,IDC_STATUSLIST,LB_SETCURSEL,SendDlgItemMessageW(hDLG,IDC_STATUSLIST,LB_ADDSTRING,0,dword(PWideChar(msg))),0);
+ SendDlgItemMessageW(hDLG,IDC_STATUSLIST,LB_SETCURSEL,
+ SendDlgItemMessageW(hDLG,IDC_STATUSLIST,LB_ADDSTRING,0,lparam(PWideChar(msg))),0);
end;
procedure FillComboBox(hDlg:hWnd); //Заполняем список именами шаблонов
var
i:integer;
begin
- ITDD.PattFError:=true;
- ReadPatterns;
- SendDlgItemMessage(hDlg,IDC_TYPECOMBO,CB_RESETCONTENT,0,0);
- if PatternsCount>0 then
+ ITDD.PattFError:=true;
+ ReadPatterns;
+ SendDlgItemMessage(hDLG, IDC_TYPECOMBO, CB_RESETCONTENT, 0, 0);
+ if Length(TxtPatterns) > 0 then
begin
- For i:=0 to PatternsCount-1 do
- SendDlgItemMessage(hDlg,IDC_TYPECOMBO,CB_ADDSTRING,0,Integer(PatternNames[i]));
- ITDD.PattFError:=false;
+ For i := 0 to High(TxtPatterns) do
+ SendDlgItemMessage(hDLG, IDC_TYPECOMBO, CB_ADDSTRING, 0, lparam(PChar(TxtPatterns[i].Name)));
+ ITDD.PattFError := false;
end
- else
+ else
begin
- AddStatusMessage(hDlg,TranslateWideString('No Files Patterns Found'));
- EnableWindow(GetDlgItem(hDlg, IDC_TYPECOMBO), FALSE);
- ITDD.ChoPatt:=false;
+ AddStatusMessage(hDLG, TranslateWideString('No Files Patterns Found'));
+ EnableWindow(GetDlgItem(hDLG, IDC_TYPECOMBO), false);
+ ITDD.ChoPatt := false;
end;
end;
-procedure MStart(hDlg:hWnd); //проверяем всё ли сделано чтоб начать импорт
-begin
-with ITDD do
+procedure MStart(hDLG: HWnd); //проверяем всё ли сделано чтоб начать импорт
begin
-if ChoFile and ChoPatt and (not PattFError) then
- begin
- CanStart:=true;
- EnableWindow(GetDlgItem(hDlg, IDSTART), TRUE);
- end
- else
- begin
- CanStart:=false;
- EnableWindow(GetDlgItem(hDlg, IDSTART), FALSE);
- end;
-end;
+ with ITDD do
+ begin
+ CanStart := ChoFile and ChoPatt and (not PattFError);
+ EnableWindow(GetDlgItem(hDLG, IDSTART), CanStart);
+ end;
end;
-
-function IDMainWndProc(Dialog:HWnd; hMessage,wParam,lParam:DWord):integer; stdcall;
+function IDMainWndProc(Dialog:HWnd; hMessage:uint;wParam:WPARAM;lParam:LPARAM):lresult; stdcall;
//Процедура окна диалога
var
- s:WideString;
- tempwstr:PWideChar;
-
-var H,Mi,sec,ms:word;
+ s:WideString;
+ tempwstr:PWideChar;
+ H,Mi,sec,ms:word;
begin
- result:=0;
- case hMessage of
- WM_DESTROY: begin
- if ITDD.ImportThrd<>Nil then ITDD.ImportThrd.Terminate;
- SetLastPattern(SendDlgItemMessage(Dialog, IDC_TYPECOMBO, CB_GETCURSEL, 0, 0));
- end;
- WM_INITDIALOG: begin
- TranslateDialogDefault(Dialog);
- tempwstr:=ANSIToWide(PChar(GetContactDisplayName(lParam)),tempwstr,cp);
- s:=WideFormat(TranslateWideString('Import history to %s (%s)'),[tempwstr,GetContactID(lParam)]);
- SetWindowTextW(Dialog,PWideChar(s));
- SendMessage(Dialog,WM_SETICON,ICON_SMALL,LoadIcon(hInstance,MAKEINTRESOURCE(IDI_DEFAULT)));
- FillChar(ITDD,SizeOf(TImpTxtDlgData),0);
- with ITDD do begin
- cbSize:=SizeOf(TImpTxtDlgData);
- hContact:=lParam;
- CanStart:=false;
- ChoFile:=false;
- ChoPatt:=true;
- PattFError:=false;
- ITStarted:=false;
- ITFinished:=false;
- end;
-
- FillComboBox(Dialog);
- SendDlgItemMessage(Dialog, IDC_TYPECOMBO, CB_SETCURSEL, GetLastPattern, 0);
- ITDD.IndexOfPattern:=GetLastPattern;
- MStart(Dialog);
- CheckDlgButton(Dialog,IDC_CHKDUP,BST_CHECKED);
- CheckForDuplicates:=true;
- CheckDlgButton(Dialog,IDC_SHOWDUP,BST_UNCHECKED);
- CheckForDuplicates:=false;
- ShowWindow(Dialog,SW_NORMAL);
- end;
- WM_COMMAND: begin
- if (HiWord(wParam)=CBN_SELCHANGE) and (LoWord(wParam)=IDC_TYPECOMBO) then //Сделали выбор шаблона
- begin
- ITDD.ChoPatt:=true;
- ITDD.IndexOfPattern:=SendDlgItemMessage(Dialog, IDC_TYPECOMBO, CB_GETCURSEL, 0, 0);
- MStart(Dialog);
- end;
- if (HiWord(wParam)=BN_CLICKED) and (LoWord(wParam)=IDC_CHKDUP) then
- if LongBool(IsDlgButtonChecked(Dialog,IDC_CHKDUP)) then EnableWindow(GetDlgItem(Dialog, IDC_SHOWDUP), TRUE)
- else EnableWindow(GetDlgItem(Dialog, IDC_SHOWDUP), FALSE);
- case loword(wParam) of
- IDCLOSE: DestroyWindow(Dialog);
- IDC_BRWSBTN: begin //Нажали кнопку "..."
- s:=OpenDialogExecute(Dialog,0,ITDD.oFN,TxtPatterns[ITDD.IndexOfPattern].DefExtension);
- if s<>'' then ITDD.ChoFile:=true
- else ITDD.ChoFile:=false;
- SendDlgItemMessageW(Dialog, IDC_FILENAME,WM_SETTEXT,0,dword(PWideChar(s)));
+ result:= 0;
+ case hMessage of
+ WM_DESTROY:
+ begin
+ if ITDD.ImportThrd <> Nil then
+ ITDD.ImportThrd.Terminate;
+ SetLastPattern(SendDlgItemMessage(Dialog, IDC_TYPECOMBO, CB_GETCURSEL, 0, 0));
+ end;
+
+ WM_INITDIALOG:
+ begin
+ TranslateDialogDefault(Dialog);
+ tempwstr := ANSIToWide(
+ PAnsiChar(CallService(MS_CLIST_GETCONTACTDISPLAYNAME,lParam,0)),
+ tempwstr, cp);
+ s := WideFormat(TranslateWideString('Import history to %s (%s)'), [tempwstr, GetContactID(lParam)]);
+ SetWindowTextW(Dialog, PWideChar(s));
+ SendMessage(Dialog, WM_SETICON, ICON_SMALL, LoadIcon(hInstance, MAKEINTRESOURCE(IDI_DEFAULT)));
+ FillChar(ITDD, SizeOf(TImpTxtDlgData), 0);
+ with ITDD do
+ begin
+ cbSize := SizeOf(TImpTxtDlgData);
+ hContact := lParam;
+ CanStart := false;
+ ChoFile := false;
+ ChoPatt := true;
+ PattFError := false;
+ ITStarted := false;
+ ITFinished := false;
+ end;
+
+ FillComboBox(Dialog);
+ SendDlgItemMessage(Dialog, IDC_TYPECOMBO, CB_SETCURSEL, GetLastPattern, 0);
+ ITDD.IndexOfPattern := GetLastPattern;
+ MStart(Dialog);
+ CheckDlgButton(Dialog, IDC_CHKDUP, BST_CHECKED);
+ CheckForDuplicates := true;
+ CheckDlgButton(Dialog, IDC_SHOWDUP, BST_UNCHECKED);
+ CheckForDuplicates := false;
+ ShowWindow(Dialog, SW_NORMAL);
+ end;
+
+ WM_COMMAND:
+ begin
+ if (HiWord(wParam) = CBN_SELCHANGE) and (LoWord(wParam) = IDC_TYPECOMBO) then // Сделали выбор шаблона
+ begin
+ ITDD.ChoPatt := true;
+ ITDD.IndexOfPattern := SendDlgItemMessage(Dialog, IDC_TYPECOMBO, CB_GETCURSEL, 0, 0);
MStart(Dialog);
- end;
- IDSTART: begin //Старт
- with ITDD do
- if CanStart then
- begin
- EnableWindow(GetDlgItem(Dialog, IDSTART), FALSE);
- EnableWindow(GetDlgItem(Dialog, IDCLOSE), FALSE);
- EnableWindow(GetDlgItem(Dialog, IDC_TYPECOMBO), FALSE);
- EnableWindow(GetDlgItem(Dialog, IDC_BRWSBTN), FALSE);
- ImportThrd:=TImportThrd.Create(TRUE);
- ImportThrd.FreeOnTerminate:=true;
- ImportThrd.DContact.hContact:=hContact;
- CheckForDuplicates:=LongBool(IsDlgButtonChecked(Dialog,IDC_CHKDUP));
- ShowDuplicates:=LongBool(IsDlgButtonChecked(Dialog,IDC_SHOWDUP));
- h:=SendDlgItemMessageW(Dialog, IDC_FILENAME,WM_GETTEXTLENGTH,0,0)+1;
- SetLength(s,h);
- SendDlgItemMessageW(Dialog, IDC_FILENAME,WM_GETTEXT,h,dword(PWideChar(s)));
- ImportThrd.FileNames:=s+#0+#0;
- ImportThrd.OffsetFileName:=oFN;
- ImportThrd.WorkPattern:=TxtPatterns[IndexOfPattern];
- ImportThrd.ParentHWND:=Dialog;
- ImportThrd.Resume;
- end;
- end;
- end;
- end;
- WM_CLOSE: begin
- DestroyWindow(Dialog);
+ end;
+
+ if (HiWord(wParam) = BN_CLICKED) and (LoWord(wParam) = IDC_CHKDUP) then
+ EnableWindow(GetDlgItem(Dialog, IDC_SHOWDUP),
+ IsDlgButtonChecked(Dialog, IDC_CHKDUP)<>BST_UNCHECKED);
+
+ case LoWord(wParam) of
+ IDCLOSE:
+ DestroyWindow(Dialog);
+ IDC_BRWSBTN:
+ begin // Нажали кнопку "..."
+ s := OpenDialogExecute(Dialog, 0, ITDD.oFN,
+ TxtPatterns[ITDD.IndexOfPattern].DefExtension);
+ ITDD.ChoFile := s <> '';
+ SendDlgItemMessageW(Dialog, IDC_FILENAME, WM_SETTEXT, 0, tlparam(PWideChar(s)));
+ MStart(Dialog);
+ end;
+ IDSTART:
+ begin // Старт
+ with ITDD do
+ if CanStart then
+ begin
+ EnableWindow(GetDlgItem(Dialog, IDSTART), false);
+ EnableWindow(GetDlgItem(Dialog, IDCLOSE), false);
+ EnableWindow(GetDlgItem(Dialog, IDC_TYPECOMBO), false);
+ EnableWindow(GetDlgItem(Dialog, IDC_BRWSBTN), false);
+ ImportThrd := TImportThrd.Create(true);
+ ImportThrd.FreeOnTerminate := true;
+ ImportThrd.DContact.hContact := hContact;
+ CheckForDuplicates := LongBool(IsDlgButtonChecked(Dialog, IDC_CHKDUP));
+ ShowDuplicates := LongBool(IsDlgButtonChecked(Dialog, IDC_SHOWDUP));
+ H := SendDlgItemMessageW(Dialog, IDC_FILENAME, WM_GETTEXTLENGTH, 0, 0) + 1;
+ SetLength(s, H);
+ SendDlgItemMessageW(Dialog, IDC_FILENAME, WM_GETTEXT, H, tlparam(PWideChar(s)));
+ ImportThrd.FileNames := s + #0 + #0;
+ ImportThrd.OffsetFileName := oFN;
+ ImportThrd.WorkPattern := TxtPatterns[IndexOfPattern];
+ ImportThrd.ParentHWND := Dialog;
+ ImportThrd.Resume;
+ end;
end;
- //Далее оброботка сообщений от потока импорта
- //Начали
- ITXT_THREAD_ALLSTARTED:begin
- ITDD.ITStarted:=true;
- ITDD.StartTime:=Time;
- end;
- ITXT_THREAD_START:begin
- AddStatusMessage(Dialog,TranslateWideString('Import started...'));
- end;
- //Известна длинна файла выставляем диапазон прогрессбара
- ITXT_THREAD_MAXPROGRESS:
- SendDlgItemMessage(Dialog,IDC_PROGRESS,PBM_SETRANGE,0,MakeLParam(0,lParam));
- //Идет прогресс ...
- ITXT_THREAD_PROGRESS:
- SendDlgItemMessage(Dialog,IDC_PROGRESS,PBM_SETPOS,wParam,0);
- //Возникла ошибка
- ITXT_THREAD_ERROR:
- AddStatusMessage(Dialog,TranslateWideString(PWideChar(wParam)));
- //Закончили
- ITXT_THREAD_FINISH:begin
- ITDD.ITFinished:=true;
- ITDD.FinishTime:=Time;
- DecodeTime(ITDD.FinishTime-ITDD.StartTime,h,mi,sec,ms);
- AddStatusMessage(Dialog,WideFormat(TranslateWideString('Added: %d messages'),[wParam]));
- AddStatusMessage(Dialog,WideFormat(TranslateWideString('Duplicates: %d messages'),[lParam]));
- AddStatusMessage(Dialog,WideFormat(TranslateWideString('In: %d:%d:%d'),[h,mi,sec]));
- AddStatusMessage(Dialog,'');
- SendDlgItemMessageW(Dialog, IDC_FILENAME,WM_SETTEXT,0,0);
- ITDD.ChoFile:=false;
- EnableWindow(GetDlgItem(Dialog, IDC_TYPECOMBO), TRUE);
- EnableWindow(GetDlgItem(Dialog, IDC_BRWSBTN), TRUE);
- EnableWindow(GetDlgItem(Dialog, IDCLOSE), TRUE);
- end;
- //начали новый файл
- ITXT_THREAD_START_FILE:
- AddStatusMessage(Dialog,WideFormat(TranslateWideString('File: %s'),[PWideChar(wParam)]));
- //определили контакт
- ITXT_THREAD_DEST_CONTACT:begin
- if IsMirandaUnicode then
- begin
- tempwstr:=UTF8toWide(PChar(GetContactID(wParam,'',true)),tempwstr);
- s:= tempwstr;
- tempwstr:=UTF8toWide(PChar(GetContactNick(wParam,'',true)),tempwstr);
- s:=s + ' | ' + tempwstr;
- end
- else
- s:=GetContactID(wParam,'',true)+' | '+GetContactNick(wParam,'',true);
-
- AddStatusMessage(Dialog,WideFormat(TranslateWideString('To: %s'),[s]));
- end;
+ end;
+ end;
+ WM_CLOSE:
+ begin
+ DestroyWindow(Dialog);
+ end;
+ // Далее оброботка сообщений от потока импорта
+ // Начали
+ ITXT_THREAD_ALLSTARTED:
+ begin
+ ITDD.ITStarted := true;
+ ITDD.StartTime := Time;
+ end;
+ ITXT_THREAD_START:
+ begin
+ AddStatusMessage(Dialog, TranslateWideString('Import started...'));
+ end;
+ // Известна длинна файла выставляем диапазон прогрессбара
+ ITXT_THREAD_MAXPROGRESS:
+ SendDlgItemMessage(Dialog, IDC_PROGRESS, PBM_SETRANGE, 0, MakeLParam(0, lParam));
+ // Идет прогресс ...
+ ITXT_THREAD_PROGRESS:
+ SendDlgItemMessage(Dialog, IDC_PROGRESS, PBM_SETPOS, wParam, 0);
+ // Возникла ошибка
+ ITXT_THREAD_ERROR:
+ AddStatusMessage(Dialog, TranslateWideString(PWideChar(wParam)));
+ // Закончили
+ ITXT_THREAD_FINISH:
+ begin
+ ITDD.ITFinished := true;
+ ITDD.FinishTime := Time;
+ DecodeTime(ITDD.FinishTime - ITDD.StartTime, H, Mi, sec, ms);
+ AddStatusMessage(Dialog, WideFormat(TranslateWideString('Added: %d messages'), [wParam]));
+ AddStatusMessage(Dialog, WideFormat(TranslateWideString('Duplicates: %d messages'), [lParam]));
+ AddStatusMessage(Dialog, WideFormat(TranslateWideString('In: %d:%d:%d'), [H, Mi, sec]));
+ AddStatusMessage(Dialog, '');
+ SendDlgItemMessageW(Dialog, IDC_FILENAME, WM_SETTEXT, 0, 0);
+ ITDD.ChoFile := false;
+ EnableWindow(GetDlgItem(Dialog, IDC_TYPECOMBO), true);
+ EnableWindow(GetDlgItem(Dialog, IDC_BRWSBTN), true);
+ EnableWindow(GetDlgItem(Dialog, IDCLOSE), true);
+ end;
+ // начали новый файл
+ ITXT_THREAD_START_FILE:
+ AddStatusMessage(Dialog, WideFormat(TranslateWideString('File: %s'), [PWideChar(wParam)]));
+ // определили контакт
+ ITXT_THREAD_DEST_CONTACT:
+ begin
+ s := GetContactID(wParam, '', true) + ' | ' + GetContactNick(wParam, '', true);
+
+ AddStatusMessage(Dialog, WideFormat(TranslateWideString('To: %s'), [s]));
+ end;
end;
end;
-end. \ No newline at end of file
+end.
diff --git a/plugins/Pascal_Headers/m_api.pas b/plugins/Pascal_Headers/m_api.pas
index 8441e34870..c8692b16db 100644
--- a/plugins/Pascal_Headers/m_api.pas
+++ b/plugins/Pascal_Headers/m_api.pas
@@ -92,27 +92,6 @@ const
const
UNICODE_AWARE = 1;
-type
- PPLUGININFO = ^TPLUGININFO;
- TPLUGININFO = record
- cbSize :int;
- shortName :PAnsiChar;
- version :DWORD;
- description:PAnsiChar; // [TRANSLATED-BY-CORE]
- author :PAnsiChar;
- authorEmail:PAnsiChar;
- copyright :PAnsiChar;
- homepage :PAnsiChar;
- flags :Byte; // right now the only flag, UNICODE_AWARE, is recognized here
- { one of the DEFMOD_* consts in m_plugin or zero, if non zero, this will
- suppress loading of the specified builtin module }
- replacesDefaultModule: int;
- end;
-
-{
- 0.7+
- New plugin loader implementation
-}
// The UUID structure below is used to for plugin UUID's and module type definitions
type
PMUUID = ^TMUUID;
@@ -168,14 +147,14 @@ const
{ Database plugin stuff }
// grokHeader() error codes
- const
- EGROKPRF_NOERROR = 0;
- EGROKPRF_CANTREAD = 1; // can't open the profile for reading
- EGROKPRF_UNKHEADER = 2; // header not supported, not a supported profile
- EGROKPRF_VERNEWER = 3; // header correct, version in profile newer than reader/writer
- EGROKPRF_DAMAGED = 4; // header/version fine, other internal data missing, damaged.
- // makeDatabase() error codes
- EMKPRF_CREATEFAILED = 1; // for some reason CreateFile() didnt like something
+const
+ EGROKPRF_NOERROR = 0;
+ EGROKPRF_CANTREAD = 1; // can't open the profile for reading
+ EGROKPRF_UNKHEADER = 2; // header not supported, not a supported profile
+ EGROKPRF_VERNEWER = 3; // header correct, version in profile newer than reader/writer
+ EGROKPRF_DAMAGED = 4; // header/version fine, other internal data missing, damaged.
+// makeDatabase() error codes
+ EMKPRF_CREATEFAILED = 1; // for some reason CreateFile() didnt like something
type
PDATABASELINK = ^TDATABASELINK;
@@ -215,8 +194,7 @@ type
}
grokHeader : function (profile:PAnsiChar; error:Pint):int; cdecl;
{
- Affect: Tell the database to create all services/hooks that a 3.xx legecy database might support into link,
- which is a PLUGINLINK structure
+ Affect: Tell the database to create all services/hooks that a 3.xx legecy database might support into link
Returns: 0 on success, nonzero on failure
}
Load : function (profile:PAnsiChar):int; cdecl;
diff --git a/plugins/Pascal_Headers/m_core.inc b/plugins/Pascal_Headers/m_core.inc
index a46174c193..bbf0bcba56 100644
--- a/plugins/Pascal_Headers/m_core.inc
+++ b/plugins/Pascal_Headers/m_core.inc
@@ -169,8 +169,6 @@ function SetHookDefaultForHookableEvent(hEvent:THANDLE; pfnHook:TMIRANDAHOOK):in
external CoreDLL name 'SetHookDefaultForHookableEvent';
function CallPluginEventHook(hInst:HINST; hEvent:THANDLE; wParam:WPARAM; lParam:LPARAM):int; stdcall;
external CoreDLL name 'CallPluginEventHook';
-function CallHookSubscribers(hEvent:THANDLE; wParam:WPARAM; lParam:LPARAM):int; stdcall;
- external CoreDLL name 'CallHookSubscribers';
function NotifyEventHooks(hEvent:THANDLE; wParam:WPARAM; lParam:LPARAM): int; stdcall;
external CoreDLL name 'NotifyEventHooks';
@@ -498,8 +496,8 @@ function forkthread(func:pThreadFunc; stacksize:uint; arg:pointer):uint_ptr; std
function forkthreadex(sec:pointer; stacksize:uint; func:pThreadFuncEx; owner:pointer; arg:pointer; thraddr:puint_ptr):uint_ptr; stdcall;
external CoreDLL name 'forkthreadex';
-procedure Thread_SetName(dwThreadID:dword; const szThreadName:pAnsiChar); stdcall;
- external CoreDLL name 'Thread_SetName';
+procedure Thread_SetName(const szThreadName:pAnsiChar); stdcall;
+ external CoreDLL name 'Thread_SetName';
procedure KillObjectThreads(pObject:pointer); stdcall;
external CoreDLL name 'KillObjectThreads';
@@ -507,7 +505,7 @@ procedure KillObjectThreads(pObject:pointer); stdcall;
///////////////////////////////////////////////////////////////////////////////
// utf8 interface
-
+{ commented to avoid newer Delphi version conflicts
function Utf8Decode(str:PAnsiChar; var ucs2:pWideChar):PAnsiChar;stdcall;
external CoreDLL name 'Utf8Decode';
function Utf8DecodeCP(str:PAnsiChar; codepage:int; var ucs2:pWideChar):PAnsiChar;stdcall;
@@ -526,6 +524,7 @@ function Utf8EncodeW(const src:PWideChar):PAnsiChar;stdcall;
function Ucs2toUtf8Len(const src:pWideChar):int; stdcall;
external CoreDLL name 'Ucs2toUtf8Len';
+}
// aliases
function mir_utf8decode(str:PAnsiChar; var ucs2:pWideChar):PAnsiChar;stdcall;
external CoreDLL name 'Utf8Decode';
diff --git a/plugins/Pascal_Headers/m_helpers.inc b/plugins/Pascal_Headers/m_helpers.inc
index e4297b3c16..34351ec63d 100644
--- a/plugins/Pascal_Headers/m_helpers.inc
+++ b/plugins/Pascal_Headers/m_helpers.inc
@@ -3,7 +3,7 @@
function ProtoServiceExists(const proto,service: PAnsiChar): int;
function CreateVersionString(version:dword;buf:PAnsiChar):PAnsiChar;
-function CreateVersionStringPlugin(pluginInfo:PPluginInfo;buf:PAnsiChar):PAnsiChar;
+function CreateVersionStringPlugin(pluginInfo:PPluginInfoEx;buf:PAnsiChar):PAnsiChar;
function PLUGIN_MAKE_VERSION(a,b,c,d: Cardinal): int;
function PLUGIN_CMP_VERSION(verA: LongInt; verB: LongInt): int;
@@ -35,6 +35,7 @@ function Translate(sz: PAnsiChar): PAnsiChar;
function Translatew(sz: PWideChar): PWideChar;
function TranslateString(const sz: AnsiString): AnsiString;
function TranslateWideString(const sz:WideString):WideString;
+function TranslateUnicodeString(sz: String): String;{$ifdef FPC}inline;{$endif}
procedure TranslateDialogDefault(hwndDlg: THandle);
procedure TranslateMenu(hMenu: HMENU);
function Langpack_PCharToTChar(astr:PAnsiChar):int_ptr;
@@ -100,7 +101,7 @@ begin
result:=buf;
end;
-function CreateVersionStringPlugin(pluginInfo:PPluginInfo;buf:PAnsiChar):PAnsiChar;
+function CreateVersionStringPlugin(pluginInfo:PPluginInfoEx;buf:PAnsiChar):PAnsiChar;
begin
result:=CreateVersionString(pluginInfo^.version,buf);
end;
@@ -299,6 +300,11 @@ begin
CallService(MS_LANGPACK_TRANSLATESTRING, LANG_UNICODE, lParam(sz))));
end;
+function TranslateUnicodeString(sz: String): String;{$ifdef FPC}inline;{$endif}
+begin
+ Result := String(PChar(CallService(MS_LANGPACK_TRANSLATESTRING, LANG_UNICODE, lParam(sz))));
+end;
+
procedure TranslateDialogDefault(hwndDlg: THandle);
begin
TranslateDialog_LP(hwndDlg,hLangpack);
diff --git a/plugins/Pascal_Headers/m_idle.inc b/plugins/Pascal_Headers/m_idle.inc
index c01da2367b..bda2caea84 100644
--- a/plugins/Pascal_Headers/m_idle.inc
+++ b/plugins/Pascal_Headers/m_idle.inc
@@ -53,13 +53,14 @@ const
type
PMIRANDA_IDLE_INFO = ^TMIRANDA_IDLE_INFO;
TMIRANDA_IDLE_INFO = record
- cbSize : int; // sizeof()
- idleTime: int; // idle in mins, if zero then disabled
- privacy : int; // user doesnt want other people seeing anything more than they are idle
- aaStatus: int; // status to go to when user is auto away
- aaLock : int; // the status shouldn't be unset if its set
- idleType: int;
- end;
+ cbSize : int; // sizeof()
+ idleTime : int; // idle in mins, if zero then disabled
+ privacy : int; // user doesnt want other people seeing anything more than they are idle
+ aaStatus : int; // status to go to when user is auto away
+ aaLock : int; // the status shouldn't be unset if its set
+ idleType : int;
+ idlesoundsoff: int;
+ end;
{
wParam; 0
lParam: address of MIRANDA_IDLE_INFO