/Delphi/akTimeLog/Bitmaps/help.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/Delphi/akTimeLog/Source/MainUnit.dfm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/Delphi/akTimeLog/Source/ChangePasswordUnit.pas |
---|
0,0 → 1,55 |
// akTimeLog v3.0 |
// Copyright (c) 1999-2000 Anatoli Klassen |
unit ChangePasswordUnit; |
interface |
uses |
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
StdCtrls; |
type |
TChangePasswordForm = class(TForm) |
OkButton: TButton; |
CancelButton: TButton; |
OldPasswordEdit: TEdit; |
OldPasswordLabel: TLabel; |
NewPasswordLabel: TLabel; |
NewPasswordEdit: TEdit; |
RetypeNewPasswordLabel: TLabel; |
RetypeNewPasswordEdit: TEdit; |
procedure FormShow(Sender: TObject); |
private |
public |
function Execute(var OldPwd, NewPwd, RetypeNewPwd : string) : boolean; |
end; |
var |
ChangePasswordForm: TChangePasswordForm; |
implementation |
{$R *.DFM} |
function TChangePasswordForm.Execute; |
begin |
OldPasswordEdit.Text := ''; |
NewPasswordEdit.Text := ''; |
RetypeNewPasswordEdit.Text := ''; |
Application.BringToFront; |
Result := (ShowModal = mrOk); |
if Result then begin |
OldPwd := OldPasswordEdit.Text; |
NewPwd := NewPasswordEdit.Text; |
RetypeNewPwd := RetypeNewPasswordEdit.Text; |
end; |
end; |
procedure TChangePasswordForm.FormShow(Sender: TObject); |
begin |
SetForegroundWindow(Handle); |
OldPasswordEdit.SetFocus; |
end; |
end. |
/Delphi/akTimeLog/Source/aktimelg.cfg |
---|
0,0 → 1,39 |
-$A8 |
-$B- |
-$C+ |
-$D+ |
-$E- |
-$F- |
-$G+ |
-$H+ |
-$I+ |
-$J+ |
-$K- |
-$L+ |
-$M- |
-$N+ |
-$O+ |
-$P+ |
-$Q- |
-$R- |
-$S- |
-$T- |
-$U- |
-$V+ |
-$W- |
-$X+ |
-$YD |
-$Z1 |
-cg |
-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; |
-H+ |
-W+ |
-M |
-$M16384,1048576 |
-K$00400000 |
-E"..\Exe" |
-N"..\Units" |
-U"..\Units" |
-O"..\Units" |
-I"..\Units" |
-R"..\Units" |
/Delphi/akTimeLog/Source/AboutUnit.pas |
---|
0,0 → 1,57 |
// akTimeLog v3.0 |
// Copyright (c) 1999-2000 Anatoli Klassen |
unit AboutUnit; |
interface |
uses |
WinTypes, WinProcs, Classes, Graphics, Forms, Controls, StdCtrls, |
Buttons, ExtCtrls, ShellAPI; |
type |
TAboutBox = class(TForm) |
OkButton : TBitBtn; |
ProgramIcon : TImage; |
ProductName : TLabel; |
Version : TLabel; |
Copyright : TLabel; |
WebLabel: TLabel; |
MailLabel: TLabel; |
HTMLLabel: TLabel; |
MailtoLabel: TLabel; |
procedure HTMLLabelClick(Sender: TObject); |
procedure MailtoLabelClick(Sender: TObject); |
private |
public |
end; |
var |
AboutBox : TAboutBox; |
implementation |
uses SysUtils; |
{$R *.DFM} |
procedure TAboutBox.HTMLLabelClick(Sender: TObject); |
var |
URL : string; |
begin |
if (Sender is TLabel) then begin |
URL := (Sender as TLabel).Caption; |
if UpperCase(Copy(URL, 1, 7)) <> 'HTTP://' then URL := 'http://' + URL; |
ShellExecute(0, nil, PChar(URL), nil, nil, 0); |
end; |
end; |
procedure TAboutBox.MailtoLabelClick(Sender: TObject); |
begin |
ShellExecute(0, nil, PChar('mailto:' + MailtoLabel.Caption), nil, nil, 0); |
end; |
end. |
/Delphi/akTimeLog/Source/OptionsUnit.dfm |
---|
0,0 → 1,85 |
object OptionsForm: TOptionsForm |
Left = 191 |
Top = 107 |
BorderIcons = [biSystemMenu] |
BorderStyle = bsDialog |
Caption = 'Options - akTimeLog' |
ClientHeight = 125 |
ClientWidth = 340 |
Color = clBtnFace |
Font.Charset = DEFAULT_CHARSET |
Font.Color = clWindowText |
Font.Height = -11 |
Font.Name = 'MS Sans Serif' |
Font.Style = [] |
OldCreateOrder = False |
Position = poDesktopCenter |
PixelsPerInch = 96 |
TextHeight = 13 |
object AutoRunCheckBox: TCheckBox |
Left = 4 |
Top = 4 |
Width = 331 |
Height = 17 |
Anchors = [akLeft, akTop, akRight] |
Caption = 'Auto run the program on Windows start' |
TabOrder = 0 |
OnClick = AutoRunCheckBoxClick |
end |
object AutoRunGroupBox: TGroupBox |
Left = 4 |
Top = 24 |
Width = 331 |
Height = 65 |
Anchors = [akLeft, akTop, akRight] |
Caption = 'Auto Run options' |
TabOrder = 1 |
object UserNameLabel: TLabel |
Left = 28 |
Top = 40 |
Width = 51 |
Height = 13 |
Caption = 'User name' |
end |
object OneUserCheckBox: TCheckBox |
Left = 8 |
Top = 16 |
Width = 315 |
Height = 17 |
Anchors = [akLeft, akTop, akRight] |
Caption = 'Log only one user' |
TabOrder = 0 |
OnClick = OneUserCheckBoxClick |
end |
object UserNameEdit: TEdit |
Left = 88 |
Top = 36 |
Width = 235 |
Height = 21 |
Anchors = [akLeft, akTop, akRight] |
TabOrder = 1 |
end |
end |
object OkButton: TButton |
Left = 176 |
Top = 95 |
Width = 75 |
Height = 25 |
Anchors = [akRight, akBottom] |
Caption = 'OK' |
Default = True |
ModalResult = 1 |
TabOrder = 2 |
end |
object CancelButton: TButton |
Left = 260 |
Top = 95 |
Width = 75 |
Height = 25 |
Anchors = [akRight, akBottom] |
Cancel = True |
Caption = 'Cancel' |
ModalResult = 2 |
TabOrder = 3 |
end |
end |
/Delphi/akTimeLog/Source/aktimelg.dof |
---|
0,0 → 1,84 |
[FileVersion] |
Version=6.0 |
[Compiler] |
A=8 |
B=0 |
C=1 |
D=1 |
E=0 |
F=0 |
G=1 |
H=1 |
I=1 |
J=1 |
K=0 |
L=1 |
M=0 |
N=1 |
O=1 |
P=1 |
Q=0 |
R=0 |
S=0 |
T=0 |
U=0 |
V=1 |
W=0 |
X=1 |
Y=1 |
Z=1 |
ShowHints=1 |
ShowWarnings=1 |
UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; |
[Linker] |
MapFile=0 |
OutputObjs=0 |
ConsoleApp=1 |
DebugInfo=0 |
RemoteSymbols=0 |
MinStackSize=16384 |
MaxStackSize=1048576 |
ImageBase=4194304 |
ExeDescription= |
[Directories] |
OutputDir=..\Exe |
UnitOutputDir=..\Units |
PackageDLLOutputDir= |
PackageDCPOutputDir= |
SearchPath=..\Units |
Packages=VCL40;VCLX40;VCLDB40;VCLDBX40;VCLSMP40;QRPT40;TEEUI40;TEEDB40;TEE40;ibevnt40;nmfast40 |
Conditionals= |
DebugSourceDirs= |
UsePackages=0 |
[Parameters] |
RunParams= |
HostApplication= |
Launcher= |
UseLauncher=0 |
DebugCWD= |
[Version Info] |
IncludeVerInfo=1 |
AutoIncBuild=1 |
MajorVer=3 |
MinorVer=0 |
Release=0 |
Build=0 |
Debug=0 |
PreRelease=0 |
Special=0 |
Private=0 |
DLL=0 |
Locale=1033 |
CodePage=1252 |
[Version Info Keys] |
CompanyName=Anatoli Klassen |
FileDescription=akTimeLog |
FileVersion=3.0.0.0 |
InternalName=akTimeLog |
LegalCopyright=(c) 1999-2000 Anatoli Klassen |
LegalTrademarks= |
OriginalFilename=aktimelg.exe |
ProductName=akTimeLog |
ProductVersion=3.0.0 |
Comments=freeware |
Home Page=www.aksoft.net/progs/aktimelog |
/Delphi/akTimeLog/Source/MainUnit.pas |
---|
0,0 → 1,746 |
// akTimeLog v3.0 |
// Copyright (c) 1999-2000 Anatoli Klassen |
unit MainUnit; |
interface |
uses |
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
StdCtrls, ComCtrls, Menus, ShellApi, ExtCtrls, ImgList, AMAutoRun, |
UtilsUnit, LogInfoUnit; |
const |
AK_NOTIFYICON = WM_USER + 2; |
ID_ICON = 1; |
type |
TakTimeLogMainForm = class(TForm) |
MainMenu: TMainMenu; |
FileMenu: TMenuItem; |
ExitItem: TMenuItem; |
HelpMenu: TMenuItem; |
AboutItem: TMenuItem; |
StatusBar: TStatusBar; |
IconPopupMenu: TPopupMenu; |
ShowPopupItem: TMenuItem; |
PopupMenuLine03: TMenuItem; |
ExitPopupItem: TMenuItem; |
Timer: TTimer; |
MenuLine01: TMenuItem; |
ChangePasswordItem: TMenuItem; |
OptionsItem: TMenuItem; |
HelpContentsItem: TMenuItem; |
MenuImageList: TImageList; |
PopupMenuLine01: TMenuItem; |
ChangePasswordPopupItem: TMenuItem; |
OptionsPopupItem: TMenuItem; |
PopupMenuLine02: TMenuItem; |
AboutPopupItem: TMenuItem; |
HelpContentsPopupItem: TMenuItem; |
AutoRun: TAMAutoRun; |
TimeTree: TTreeView; |
TreePopupMenu: TPopupMenu; |
DeleteBranchPopupItem: TMenuItem; |
EditMenu: TMenuItem; |
DeleteBranchItem: TMenuItem; |
procedure FormCreate(Sender: TObject); |
procedure ExitItemClick(Sender: TObject); |
procedure AboutItemClick(Sender: TObject); |
procedure ShowPopupItemClick(Sender: TObject); |
procedure FormHide(Sender: TObject); |
procedure TimerTimer(Sender: TObject); |
procedure FormDestroy(Sender: TObject); |
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); |
procedure ChangePasswordItemClick(Sender: TObject); |
procedure OptionsItemClick(Sender: TObject); |
procedure HelpContentsItemClick(Sender: TObject); |
procedure DeleteBranchItemClick(Sender: TObject); |
procedure TimeTreeChange(Sender: TObject; Node: TTreeNode); |
procedure TimeTreeKeyUp(Sender: TObject; var Key: Word; |
Shift: TShiftState); |
private |
FShow : boolean; |
FExit : boolean; // Exit item was clicked |
FProgStart : TDateTime; |
procedure IconCallBack(var WMN : TWMNotify); message AK_NOTIFYICON; |
procedure SendParams(var WMN : TWMNotify); message AK_SENDPARAM; |
procedure EndSession(var WMN : TWMNotify); message WM_QUERYENDSESSION; |
procedure AddIcon; |
procedure DeleteIcon; |
procedure ModifyIcon(Tip : string); |
procedure AppMinimize(Sender : TObject); |
procedure CalcTime; |
procedure DeleteTimeBranch(Branch : TTreeNode); |
procedure DeleteTime(ATime : TDateTime; Kind : TInfoType); |
function EncodeTime(Pwd : string; |
Time : TDateTime; Position : longint) : Int64; |
function DecodeTime(Pwd : string; |
Code : Int64; Position : longint) : TDateTime; |
public |
procedure ShowWindow; |
end; |
var |
akTimeLogMainForm: TakTimeLogMainForm; |
implementation |
uses AboutUnit, Registry, OptionsUnit, ChangePasswordUnit, PasswordUnit; |
{$R *.DFM} |
//= TakTimeLogMainForm ========================================================= |
procedure TakTimeLogMainForm.FormCreate(Sender: TObject); |
var |
Reg : TRegIniFile; |
LogFile : file of Int64; |
StartCode : Int64; |
StopCode : Int64; |
Pwd : string; |
begin |
try |
Reg := TRegIniFile.Create(RegistryRoot); |
Top := Reg.ReadInteger('Main Window', 'Top', Top); |
Left := Reg.ReadInteger('Main Window', 'Left', Left); |
Width := Reg.ReadInteger('Main Window', 'Width', Width); |
Height := Reg.ReadInteger('Main Window', 'Height', Height); |
Reg.Free; |
except |
end; |
Application.OnMinimize := AppMinimize; |
FExit := False; |
FShow := False; |
AddIcon; |
if WriteLog then |
try |
System.Assign(LogFile, LogFileName); |
try |
System.Reset(LogFile); |
System.Seek(LogFile, FileSize(LogFile)); |
except |
System.Rewrite(LogFile); |
end; |
Pwd := DecodePassword(Password); |
FProgStart := Now; |
StartCode := EncodeTime(Pwd, FProgStart, System.FilePos(LogFile)); |
StopCode := EncodeTime(Pwd, FProgStart, System.FilePos(LogFile)+1); |
Write(LogFile, StartCode); |
Write(LogFile, StopCode); |
System.Close(LogFile); |
ModifyIcon('akTimeLog - Started ' + DateTimeToStr(FProgStart)); |
except |
MessageBox(0, PChar('Error writting ' + LogFileName), |
'akTimeLog', MB_ICONERROR or MB_OK); |
end; |
Timer.Enabled := True; |
ShowPopupItem.Enabled := not Application.ShowMainForm; |
end; |
procedure TakTimeLogMainForm.CalcTime; |
procedure AddItem(Info : TLogInfo); |
var |
Node : TTreeNode; |
begin |
case Info.InfoType of |
itYear: Node := nil; |
itMonth: begin |
Node := TimeTree.Items.GetFirstNode; |
while (Node <> nil) and not (((TLogInfo(Node.Data)).InfoType = itYear) |
and ((TLogInfo(Node.Data)).Year = Info.Year)) |
do Node := Node.GetNext; |
end; |
itDay: begin |
Node := TimeTree.Items.GetFirstNode; |
while (Node <> nil) and not (((TLogInfo(Node.Data)).InfoType = itMonth) |
and ((TLogInfo(Node.Data)).Month = Info.Month)) |
do Node := Node.GetNext; |
end; |
itTime: begin |
Node := TimeTree.Items.GetFirstNode; |
while (Node <> nil) and not (((TLogInfo(Node.Data)).InfoType = itDay) |
and ((TLogInfo(Node.Data)).Day = Info.Day)) |
do Node := Node.GetNext; |
end; |
else Exit; |
end; |
Node := TimeTree.Items.AddChild(Node, ''); |
Node.Data := Info; |
end; |
procedure UpdateItems; |
var |
Node : TTreeNode; |
Y, M, D : word; |
begin |
DecodeDate(Now, Y, M, D); |
Node := TimeTree.Items.GetFirstNode; |
while Node <> nil do |
with TLogInfo(Node.Data) do begin |
Node.Text := ToString; |
case InfoType of |
itYear : if Year = Y then Node.Expand(False); |
itMonth : if Month = M then Node.Expand(False); |
itDay : if Day = D then Node.Expand(False); |
end; |
Node := Node.GetNext; |
end; |
end; |
var |
Pwd : string; |
LogFile : file of Int64; |
StartCode : Int64; |
StopCode : Int64; |
StartTime : TDateTime; |
StopTime : TDateTime; |
Time1 : TDateTime; |
Time2 : TDateTime; |
Year, Month, Day, Time, Total : TLogInfo; |
begin |
DeleteTimeBranch(nil); |
try |
System.Assign(LogFile, LogFileName); |
System.Reset(LogFile); |
Pwd := DecodePassword(Password); |
Total := nil; |
Year := nil; |
Month := nil; |
Day := nil; |
while not EoF(LogFile) do begin |
Read(LogFile, StartCode, StopCode); |
StartTime := DecodeTime(Pwd, StartCode, System.FilePos(LogFile)-2); |
StopTime := DecodeTime(Pwd, StopCode, System.FilePos(LogFile)-1); |
if StopTime < StartTime then begin |
Application.MessageBox(PChar('Incorrect record in ' + LogFileName), |
'akTimeLog', MB_OK or MB_ICONERROR); |
Break; |
end; |
Time1 := StartTime; |
Time2 := Trunc(Time1)+1; |
repeat |
if Time2 > StopTime then Time2 := StopTime; |
Time := TLogInfo.Create(itTime, Time1, Time2); |
if Total = nil then Total := TLogInfo.Create(itTotal, Time1, Time1); |
if (Year = nil) or (Year.Year <> Time.Year) then begin |
Year := TLogInfo.Create(itYear, Time1, Time1); |
AddItem(Year); |
end; |
if (Month = nil) or (Month.Month <> Time.Month) then begin |
Month := TLogInfo.Create(itMonth, Time1, Time1); |
AddItem(Month); |
end; |
if (Day = nil) or (Day.Day <> Time.Day) then begin |
Day := TLogInfo.Create(itDay, Time1, Time1); |
AddItem(Day); |
end; |
AddItem(Time); |
Total.AddTime(Time.Duration); |
Year.AddTime(Time.Duration); |
Month.AddTime(Time.Duration); |
Day.AddTime(Time.Duration); |
if Time2 >= StopTime then Break; |
Time1 := Trunc(Time1)+1; |
Time2 := Trunc(Time1)+1; |
until False; |
end; |
System.Close(LogFile); |
UpdateItems; |
StatusBar.Panels[0].Text := Total.ToString; |
Total.Free; |
except |
Application.MessageBox(PChar('Error reading ' + LogFileName), |
'akTimeLog', MB_OK or MB_ICONERROR); |
end; |
end; |
procedure TakTimeLogMainForm.DeleteTimeBranch(Branch : TTreeNode); |
var |
Node, Node2 : TTreeNode; |
begin |
if Branch = nil then |
Node := TimeTree.Items.GetFirstNode |
else |
Node := Branch.GetFirstChild; |
while Node <> nil do begin |
DeleteTimeBranch(Node); |
if Node.Data <> nil then TLogInfo(Node.Data).Free; |
Node2 := Node.GetNextSibling; |
Node.Delete; |
Node := Node2; |
end; |
end; |
procedure TakTimeLogMainForm.AddIcon; |
var |
ID : TNotifyIconData; |
begin |
if not WriteLog then Exit; |
ID.cbSize := SizeOf(ID); |
ID.Wnd := Handle; |
ID.uID := ID_ICON; |
ID.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP; |
ID.uCallbackMessage := AK_NOTIFYICON; |
ID.hIcon := Icon.Handle; |
ID.szTip := 'akTimeLog'; |
Shell_NotifyIcon(NIM_ADD, @ID); |
end; |
procedure TakTimeLogMainForm.ModifyIcon(Tip : string); |
var |
ID : TNotifyIconData; |
begin |
if not WriteLog then Exit; |
ID.cbSize := SizeOf(ID); |
ID.Wnd := Handle; |
ID.uID := ID_ICON; |
ID.uFlags := NIF_TIP; |
StrPCopy(ID.szTip, Copy(Tip, 1, 62)); |
Shell_NotifyIcon(NIM_MODIFY, @ID); |
end; |
procedure TakTimeLogMainForm.DeleteIcon; |
var |
ID : TNotifyIconData; |
begin |
if not WriteLog then Exit; |
ID.cbSize := SizeOf(ID); |
ID.Wnd := Handle; |
ID.uID := ID_ICON; |
Shell_NotifyIcon(NIM_DELETE, @ID); |
end; |
procedure TakTimeLogMainForm.IconCallBack; |
var |
p : TPoint; |
begin |
inherited; |
case longint(WMN.NMHdr) of |
WM_RBUTTONUP: begin |
GetCursorPos(p); |
IconPopupMenu.Popup(p.x, p.y); |
end; |
WM_LBUTTONDBLCLK: begin |
ShowWindow; |
Application.Restore; |
Application.BringToFront; |
end; |
end; |
end; |
procedure TakTimeLogMainForm.AppMinimize(Sender : TObject); |
begin |
if WriteLog then Hide; |
end; |
procedure TakTimeLogMainForm.ShowPopupItemClick(Sender: TObject); |
begin |
ShowWindow; |
Application.Restore; |
Application.BringToFront; |
end; |
procedure TakTimeLogMainForm.FormHide(Sender: TObject); |
begin |
ShowPopupItem.Enabled := True; |
end; |
procedure TakTimeLogMainForm.DeleteTime(ATime : TDateTime; Kind : TInfoType); |
type |
TTimes = array[0..MaxInt div 32] of TLogInfo; |
var |
LogFile : file of Int64; |
Times : ^TTimes; |
n, i, k : longint; |
Code1, Code2 : Int64; |
Pwd : string; |
CurWritten : boolean; |
TimeNow : TDateTime; |
ControlTime : TLogInfo; |
begin |
try |
Pwd := DecodePassword(Password); |
CurWritten := False; |
System.Assign(LogFile, LogFileName); |
System.Reset(LogFile); |
GetMem(Times, System.FileSize(LogFile) * SizeOf(Pointer) div 2); |
n := 0; |
while not EoF(LogFile) do begin |
Read(LogFile, Code1, Code2); |
Times^[n] := TLogInfo.Create(itTime, |
DecodeTime(Pwd, Code1, n*2), |
DecodeTime(Pwd, Code2, n*2+1)); |
Inc(n); |
end; |
System.Close(LogFile); |
ControlTime := TLogInfo.Create(itTime, ATime, ATime); |
System.Rewrite(LogFile); |
k := 0; |
for i := 0 to n-1 do begin |
case Kind of |
itTotal : Continue; |
itYear : if Times^[i].Year = ControlTime.Year then Continue; |
itMonth : if Times^[i].Month = ControlTime.Month then Continue; |
itDay : if Times^[i].Day = ControlTime.Day then Continue; |
itTime : if Times^[i].Start = ControlTime.Start then Continue; |
end; |
if Times^[i].Start = FProgStart then CurWritten := True; |
Code1 := EncodeTime(Pwd, Times^[i].Start, k*2); |
Code2 := EncodeTime(Pwd, Times^[i].Stop, k*2+1); |
Write(LogFile, Code1, Code2); |
Inc(k); |
end; |
if not CurWritten then begin |
TimeNow := Now; |
Code1 := EncodeTime(Pwd, TimeNow, k*2); |
Code2 := EncodeTime(Pwd, TimeNow, k*2+1); |
Write(LogFile, Code1, Code2); |
end; |
System.Close(LogFile); |
FreeMem(Times, System.FileSize(LogFile) * SizeOf(Int64)); |
except |
end; |
end; |
procedure TakTimeLogMainForm.TimerTimer(Sender: TObject); |
var |
LogFile : file of Int64; |
CurTime : Int64; |
Pwd : string; |
begin |
if WriteLog then |
try |
System.Assign(LogFile, LogFileName); |
System.Reset(LogFile); |
System.Seek(LogFile, FileSize(LogFile)-1); |
Pwd := DecodePassword(Password); |
CurTime := EncodeTime(Pwd, Now, System.FilePos(LogFile)); |
Write(LogFile, CurTime); |
System.Close(LogFile); |
CalcTime; |
except |
MessageBox(0, PChar('Error writting ' + LogFileName), |
'akTimeLog', MB_ICONERROR or MB_OK); |
end; |
end; |
procedure TakTimeLogMainForm.FormDestroy(Sender: TObject); |
var |
Reg : TRegIniFile; |
begin |
Timer.Enabled := False; |
TimerTimer(Sender); |
DeleteIcon; |
try |
Reg := TRegIniFile.Create(RegistryRoot); |
Reg.WriteInteger('Main Window', 'Top', Top); |
Reg.WriteInteger('Main Window', 'Left', Left); |
Reg.WriteInteger('Main Window', 'Width', Width); |
Reg.WriteInteger('Main Window', 'Height', Height); |
Reg.Free; |
except |
end; |
end; |
procedure TakTimeLogMainForm.FormCloseQuery(Sender: TObject; |
var CanClose: Boolean); |
begin |
if WriteLog and not FExit then begin |
CanClose := False; |
Hide; |
end |
else |
CanClose := True; |
end; |
function TakTimeLogMainForm.EncodeTime |
(Pwd : string; Time : TDateTime; Position : longint) : Int64; |
var |
i, p : longint; |
PwdArray : array[1..8] of char; |
PwdPart : int64 absolute PwdArray; |
TimeInt : int64 absolute Time; |
begin |
Inc(Position); |
if Pwd = '' then |
Result := TimeInt |
else begin |
for i := 1 to 8 do begin |
p := (Position+i-2) mod Length(Pwd) + 1; |
PwdArray[i] := Pwd[p]; |
end; |
Result := TimeInt xor PwdPart; |
end |
end; |
function TakTimeLogMainForm.DecodeTime |
(Pwd : string; Code : Int64; Position : longint) : TDateTime; |
var |
i, p : longint; |
PwdArray : array[1..8] of char; |
PwdPart : int64 absolute PwdArray; |
Time : TDateTime absolute Code; |
begin |
Inc(Position); |
if Pwd = '' then |
Result := Time |
else begin |
for i := 1 to 8 do begin |
p := (Position+i-2) mod Length(Pwd) + 1; |
PwdArray[i] := Pwd[p]; |
end; |
Code := Code xor PwdPart; |
Result := Time; |
end |
end; |
procedure TakTimeLogMainForm.ChangePasswordItemClick(Sender: TObject); |
type |
TTimeCodes = array[0..MaxInt div 16] of Int64; |
var |
OldPwd, NewPwd : string; |
RetypeNewPwd : string; |
LogFile : file of Int64; |
TimeCodes : ^TTimeCodes; |
n, i : longint; |
TimeCode : Int64; |
begin |
if not ChangePasswordForm.Execute(OldPwd, NewPwd, RetypeNewPwd) then Exit; |
if DecodePassword(Password) <> OldPwd then begin |
Application.MessageBox('Incorrect old password', |
'akTimeLog', MB_OK or MB_ICONERROR); |
Exit; |
end; |
if (NewPwd <> '') and (NewPwd <> RetypeNewPwd) then begin |
Application.MessageBox('You''ve entered not equal new passwords', |
'akTimeLog', MB_OK or MB_ICONERROR); |
Exit; |
end; |
if DecodePassword(Password) = NewPwd then Exit; |
Password := EncodePassword(NewPwd); |
try |
System.Assign(LogFile, LogFileName); |
System.Reset(LogFile); |
GetMem(TimeCodes, System.FileSize(LogFile) * SizeOf(Int64)); |
n := 0; |
while not EoF(LogFile) do begin |
Read(LogFile, TimeCodes^[n], TimeCodes^[n+1]); |
Inc(n, 2); |
end; |
System.Close(LogFile); |
System.Rewrite(LogFile); |
for i := 0 to n-1 do begin |
TimeCode := EncodeTime(NewPwd, DecodeTime(OldPwd, TimeCodes^[i], i), i); |
Write(LogFile, TimeCode); |
end; |
System.Close(LogFile); |
FreeMem(TimeCodes, System.FileSize(LogFile) * SizeOf(Int64)); |
except |
end; |
end; |
procedure TakTimeLogMainForm.OptionsItemClick(Sender: TObject); |
begin |
OptionsForm.Execute; |
end; |
procedure TakTimeLogMainForm.ExitItemClick(Sender: TObject); |
begin |
FExit := True; |
Close; |
end; |
procedure TakTimeLogMainForm.HelpContentsItemClick(Sender: TObject); |
begin |
; |
end; |
procedure TakTimeLogMainForm.AboutItemClick(Sender: TObject); |
begin |
AboutBox.ShowModal; |
end; |
procedure TakTimeLogMainForm.SendParams(var WMN : TWMNotify); |
var |
Params : string; |
LogFile : file of Int64; |
StartCode : Int64; |
StopCode : Int64; |
StartTime : TDateTime; |
Pwd : string; |
begin |
if MapHandle = 0 then Exit; |
Params := MapFile; |
DeleteIcon; |
ParseParamsString(Params); |
AddIcon; |
if WriteLog then |
try |
System.Assign(LogFile, LogFileName); |
try |
System.Reset(LogFile); |
System.Seek(LogFile, FileSize(LogFile)); |
except |
System.Rewrite(LogFile); |
end; |
Pwd := DecodePassword(Password); |
StartTime := Now; |
StartCode := EncodeTime(Pwd, StartTime, System.FilePos(LogFile)); |
StopCode := EncodeTime(Pwd, StartTime, System.FilePos(LogFile)+1); |
Write(LogFile, StartCode); |
Write(LogFile, StopCode); |
System.Close(LogFile); |
ModifyIcon('akTimeLog - Started ' + DateTimeToStr(StartTime)); |
except |
MessageBox(0, PChar('Error writting ' + LogFileName), |
'akTimeLog', MB_ICONERROR or MB_OK); |
end |
else |
Show; |
end; |
procedure TakTimeLogMainForm.EndSession(var WMN : TWMNotify); |
begin |
FExit := True; |
WMN.Result := 1; |
end; |
procedure TakTimeLogMainForm.ShowWindow; |
var |
Pwd, Control : string; |
begin |
DeleteTimeBranch(nil); |
ShowPopupItem.Enabled := False; |
if Password <> '' then begin |
Pwd := PasswordForm.Execute; |
if Pwd = '' then Exit; |
try |
Control := DecodePassword(Password); |
except |
Application.MessageBox('Error during decoding the password', |
'akTimeLog', MB_OK or MB_ICONERROR); |
end; |
if Pwd <> Control then begin |
Application.MessageBox('Password Incorrect', 'akTimeLog', |
MB_OK or MB_ICONERROR); |
Exit; |
end; |
end; |
DeleteBranchItem.Enabled := False; |
DeleteBranchPopupItem.Enabled := False; |
CalcTime; |
Show; |
end; |
procedure TakTimeLogMainForm.DeleteBranchItemClick(Sender: TObject); |
begin |
if Application.MessageBox('Delete selected branch?', 'akTimeLog', |
MB_YESNO or MB_ICONWARNING) = IDYES |
then begin |
with TLogInfo(TimeTree.Selected.Data) do |
DeleteTime(Start, InfoType); |
CalcTime; |
end; |
end; |
procedure TakTimeLogMainForm.TimeTreeChange(Sender: TObject; |
Node: TTreeNode); |
begin |
DeleteBranchItem.Enabled := True; |
DeleteBranchPopupItem.Enabled := True; |
end; |
procedure TakTimeLogMainForm.TimeTreeKeyUp(Sender: TObject; var Key: Word; |
Shift: TShiftState); |
begin |
if Key = VK_DELETE then DeleteBranchItemClick(Sender); |
end; |
end. |
/Delphi/akTimeLog/Source/PasswordUnit.dfm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/Delphi/akTimeLog/Source/ChangePasswordUnit.dfm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/Delphi/akTimeLog/Source/OptionsUnit.pas |
---|
0,0 → 1,74 |
// akTimeLog v3.0 |
// Copyright (c) 1999-2000 Anatoli Klassen |
unit OptionsUnit; |
interface |
uses |
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
StdCtrls; |
type |
TOptionsForm = class(TForm) |
AutoRunCheckBox: TCheckBox; |
AutoRunGroupBox: TGroupBox; |
OneUserCheckBox: TCheckBox; |
UserNameLabel: TLabel; |
UserNameEdit: TEdit; |
OkButton: TButton; |
CancelButton: TButton; |
procedure AutoRunCheckBoxClick(Sender: TObject); |
procedure OneUserCheckBoxClick(Sender: TObject); |
private |
public |
procedure Execute; |
end; |
var |
OptionsForm: TOptionsForm; |
implementation |
uses MainUnit, UtilsUnit; |
{$R *.DFM} |
procedure TOptionsForm.Execute; |
begin |
AutoRunCheckBox.Checked := akTimeLogMainForm.AutoRun.Registered; |
OneUserCheckBox.Checked := arOneUserOnly; |
UserNameEdit.Text := arUserName; |
AutoRunCheckBoxClick(Self); |
if ShowModal = mrOk then begin |
arOneUserOnly := OneUserCheckBox.Checked; |
arUserName := UserNameEdit.Text; |
if AutoRunCheckBox.Checked then begin |
akTimeLogMainForm.AutoRun.Params := GetAutoRunParams; |
akTimeLogMainForm.AutoRun.Register; |
end |
else |
akTimeLogMainForm.AutoRun.UnRegister; |
end; |
end; |
procedure TOptionsForm.AutoRunCheckBoxClick(Sender: TObject); |
begin |
AutoRunGroupBox.Enabled := AutoRunCheckBox.Checked; |
OneUserCheckBox.Enabled := AutoRunGroupBox.Enabled; |
OneUserCheckBoxClick(Sender); |
end; |
procedure TOptionsForm.OneUserCheckBoxClick(Sender: TObject); |
begin |
UserNameLabel.Enabled := AutoRunGroupBox.Enabled and OneUserCheckBox.Checked; |
UserNameEdit.Enabled := AutoRunGroupBox.Enabled and OneUserCheckBox.Checked; |
end; |
end. |
/Delphi/akTimeLog/Source/AboutUnit.dfm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/Delphi/akTimeLog/Source/LogInfoUnit.pas |
---|
0,0 → 1,142 |
// akTimeLog v3.0 |
// Copyright (c) 1999-2000 Anatoli Klassen |
unit LogInfoUnit; |
interface |
type |
TInfoType = (itTotal, itYear, itMonth, itDay, itTime); |
TLogInfo = class |
private |
FStart, FStop, FDuration : TDateTime; |
FYear, FMonth, FDay : longint; |
FInfoType : TInfoType; |
procedure SetStart(Start : TDateTime); |
procedure SetStop(Stop : TDateTime); |
procedure SetDuration(Duration : TDateTime); |
procedure Decode; |
function FullTimeToStr(DateTime : TDateTime) : string; |
function ShortTimeToStr(DateTime : TDateTime) : string; |
function TimeToString : string; |
function DateToString : string; |
function MonthToStr : string; |
public |
property Start : TDateTime read FStart write SetStart; |
property Stop : TDateTime read FStop write SetStop; |
property Duration : TDateTime read FDuration write SetDuration; |
property Year : longint read FYear; |
property Month : longint read FMonth; |
property Day : longint read FDay; |
property InfoType : TInfoType read FInfoType write FInfoType; |
constructor Create(InfoType : TInfoType; Start, Stop : TDateTime); |
procedure AddTime(ATime : TDateTime); |
function ToString : string; |
end; |
implementation |
uses SysUtils; |
//= TLogInfo =================================================================== |
constructor TLogInfo.Create(InfoType : TInfoType; Start, Stop : TDateTime); |
begin |
inherited Create; |
FInfoType := InfoType; |
FStart := Start; |
FStop := Stop; |
FDuration := Stop - Start; |
Decode; |
end; |
procedure TLogInfo.SetStart(Start : TDateTime); |
begin |
FStart := Start; |
FDuration := Stop - Start; |
Decode; |
end; |
procedure TLogInfo.SetStop(Stop : TDateTime); |
begin |
FStop := Stop; |
FDuration := Stop - Start; |
end; |
procedure TLogInfo.SetDuration(Duration : TDateTime); |
begin |
FDuration := Duration; |
FStop := FStart + FDuration; |
end; |
procedure TLogInfo.AddTime(ATime : TDateTime); |
begin |
Duration := Duration + ATime; |
end; |
procedure TLogInfo.Decode; |
var |
Y, M, D : word; |
begin |
DecodeDate(FStart, Y, M, D); |
FYear := Y; |
FMonth := M; |
FDay := D; |
end; |
function TLogInfo.FullTimeToStr(DateTime : TDateTime) : string; |
var |
Hours : longint; |
begin |
Hours := Trunc(DateTime * 24); |
Result := Format('%d:%.2d', [Hours, Round((DateTime-Hours/24)*60)]); |
end; |
function TLogInfo.ShortTimeToStr(DateTime : TDateTime) : string; |
begin |
Result := TimeToStr(DateTime-Trunc(DateTime)); |
Result := Copy(Result, 0, Length(Result) - 3); |
end; |
function TLogInfo.TimeToString : string; |
begin |
Result := ShortTimeToStr(FStart) + ' - ' + ShortTimeToStr(FStop); |
end; |
function TLogInfo.DateToString : string; |
begin |
Result := DateToStr(FStart) + ' -> ' + FullTimeToStr(FDuration); |
end; |
function TLogInfo.MonthToStr : string; |
const |
MonthNames : array[1..12] of string = ( |
'January', 'February', 'March', 'April', |
'May', 'June', 'July', 'August', |
'September', 'October', 'November', 'December' |
); |
begin |
Result := MonthNames[FMonth] + ' ' + IntToStr(FYear); |
end; |
function TLogInfo.ToString : string; |
begin |
case FInfoType of |
itTotal : |
Result := 'From ' + DateToStr(FStart) + ' to ' + DateToStr(FStop) |
+ ' -> ' + FullTimeToStr(FDuration); |
itYear : |
Result := IntToStr(FYear) + ' -> ' + FullTimeToStr(FDuration); |
itMonth : |
Result := MonthToStr + ' -> ' + FullTimeToStr(FDuration); |
itDay: |
Result := DateToString; |
else |
Result := TimeToString; |
end; |
end; |
end. |
/Delphi/akTimeLog/Source/aktimelg.dpr |
---|
0,0 → 1,35 |
// akTimeLog v3.0 |
// Copyright (c) 1999-2000 Anatoli Klassen |
program aktimelg; |
uses |
Forms, |
Windows, |
UtilsUnit in 'UtilsUnit.pas', |
MainUnit in 'MainUnit.pas' {akTimeLogMainForm}, |
ChangePasswordUnit in 'ChangePasswordUnit.pas' {ChangePasswordForm}, |
OptionsUnit in 'OptionsUnit.pas' {OptionsForm}, |
PasswordUnit in 'PasswordUnit.pas' {PasswordForm}, |
LogInfoUnit in 'LogInfoUnit.pas', |
AboutUnit in 'AboutUnit.pas' {AboutBox}; |
{$R *.RES} |
begin |
if ExitRequest then Exit; |
Application.ShowMainForm := False; |
Application.Initialize; |
Application.Title := 'akTimeLog'; |
Application.CreateForm(TakTimeLogMainForm, akTimeLogMainForm); |
Application.CreateForm(TChangePasswordForm, ChangePasswordForm); |
Application.CreateForm(TOptionsForm, OptionsForm); |
Application.CreateForm(TPasswordForm, PasswordForm); |
Application.CreateForm(TAboutBox, AboutBox); |
if ShowWindow then begin |
akTimeLogMainForm.ShowWindow; |
if not akTimeLogMainForm.Visible then Exit; |
end; |
Application.Run; |
end. |
/Delphi/akTimeLog/Source/UtilsUnit.pas |
---|
0,0 → 1,249 |
// akTimeLog v3.0 |
// Copyright (c) 1999-2000 Anatoli Klassen |
unit UtilsUnit; |
interface |
uses |
Windows, Messages, Forms, SysUtils; |
const |
MapHandle : THandle = 0; |
MapFile : PChar = nil; |
AK_SENDPARAM = WM_USER + 1; |
RegistryRoot = 'Software\Anatoli Klassen\akTimeLog'; |
WriteLog : boolean = False; |
ShowWindow : boolean = True; |
LogFileName : string = ''; |
Password : string = ''; |
arUserName : string = ''; |
arOneUserOnly : boolean = False; |
var |
ExitRequest : boolean; |
function AddSlash(S : string) : string; |
function FindExistingCopy : boolean; |
procedure ParseCommandLine; |
procedure ParseParamsString(Params : string); |
function EncodePassword(Pwd : string) : string; |
function DecodePassword(Code : string) : string; |
function GetAutoRunParams : string; |
implementation |
uses Registry, Dialogs; |
const |
CommandParamsMapFileName = 'akTimeLog_CommandParamsMapFile'; |
MemFileSize = 1024; |
PasswordKey = 'JOnefv)h32n32GDl210234-#+2<()bweg94208<'; // for password |
// encoding |
var |
FExists : boolean; |
function FindExistingCopy : boolean; |
var |
Param : string; |
i : longint; |
ExistingInstance : HWND; |
begin |
MapHandle := CreateFileMapping(HWND($FFFFFFFF), nil, |
PAGE_READWRITE, 0, MemFileSize, CommandParamsMapFileName); |
Result := (GetLastError = ERROR_ALREADY_EXISTS); |
FExists := Result; |
if MapHandle = 0 then begin |
Application.MessageBox('Error creating mapping file', 'FHOP IDE', |
MB_OK or MB_ICONERROR); |
Exit; |
end; |
if Result then begin |
ExistingInstance := FindWindow('TakTimeLogMainForm', nil); |
if ExistingInstance = NULL then begin |
Application.MessageBox('Error searching existing instance', 'FHOP IDE', |
MB_OK or MB_ICONERROR); |
Exit; |
end; |
MapFile := MapViewOfFile(MapHandle, FILE_MAP_WRITE, 0, 0, 0); |
Param := ''; |
for i := 1 to ParamCount do |
Param := Param + ParamStr(i) + #0; |
Param := Param + #0; |
StrPCopy(MapFile, Param); |
SendMessage(ExistingInstance, AK_SENDPARAM, 0, 0); |
SetForegroundWindow(ExistingInstance); |
end |
else begin |
MapFile := MapViewOfFile(MapHandle, FILE_MAP_WRITE, 0, 0, 0); |
end; |
end; |
procedure ParseCommandLine; |
var |
i : longint; |
st : string; |
begin |
st := ''; |
for i := 1 to ParamCount do begin |
st := st + ParamStr(i) + ' '; |
end; |
ParseParamsString(st); |
end; |
procedure ParseParamsString(Params : string); |
var |
n : longint; |
st : string; |
Buf : PChar; |
BufSize : Cardinal; |
function GetNextParam : string; |
begin |
while (n <= Length(Params)) and (Params[n] = ' ') do Inc(n); |
Result := ''; |
if Params[n] = '"' then begin |
Inc(n); |
while (n <= Length(Params)) and (Params[n] <> '"') do begin |
Result := Result + Params[n]; |
Inc(n); |
end; |
Inc(n); |
end |
else |
while (n <= Length(Params)) and (Params[n] <> ' ') do begin |
Result := Result + Params[n]; |
Inc(n); |
end; |
end; |
begin |
WriteLog := False; |
ShowWindow := True; |
LogFileName := AddSlash(ExtractFileDir(Application.ExeName)) + 'aktimelg.dat'; |
n := 1; |
while n <= Length(Params) do begin |
st := UpperCase(GetNextParam); |
if st = '/L' then WriteLog := True |
else if st = '/U' then begin |
st := UpperCase(GetNextParam); |
GetMem(Buf, BufSize); |
if GetUserName(Buf, BufSize) and (UpperCase(StrPas(Buf)) <> st) then begin |
ExitRequest := True; |
Exit; |
end; |
FreeMem(Buf, BufSize); |
end |
else if st = '/F' then begin |
LogFileName := GetNextParam; |
end; |
end; |
ShowWindow := not WriteLog; |
end; |
function AddSlash(S : string) : string; |
begin |
if S = '' then |
Result := '' |
else |
if S[Length(S)] = '\' then |
Result := S |
else |
Result := S + '\'; |
end; |
function EncodePassword(Pwd : string) : string; |
var |
nPwd, nKey : longint; |
Digits : string; |
begin |
nKey := 1; |
Result := ''; |
for nPwd := 1 to Length(Pwd) do begin |
Digits := Format('%x', [Byte(Pwd[nPwd]) xor Byte(PasswordKey[nKey])]); |
if Length(Digits) = 1 then Digits := '0' + Digits; |
Result := Result + Digits; |
Inc(nKey); |
if nKey > Length(PasswordKey) then nKey := 1; |
end; |
end; |
function DecodePassword(Code : string) : string; |
var |
nCode, nKey : longint; |
b : byte; |
begin |
nKey := 1; |
Result := ''; |
nCode := 1; |
while nCode <= Length(Code) do begin |
b := StrToInt('$' + Copy(Code, nCode, 2)); |
Result := Result + Char(b xor Byte(PasswordKey[nKey])); |
Inc(nKey); |
if nKey > Length(PasswordKey) then nKey := 1; |
Inc(nCode, 2); |
end; |
end; |
function GetAutoRunParams : string; |
begin |
Result := '/l'; |
if arUserName <> '' then Result := Result + ' /u ' + arUserName; |
end; |
var |
Reg : TRegIniFile; |
initialization |
ExitRequest := FindExistingCopy; |
ParseCommandLine; |
try |
Reg := TRegIniFile.Create(RegistryRoot); |
Password := Reg.ReadString('Settings', 'Password', ''); |
arOneUserOnly := Reg.ReadBool('Settings', 'AR One User', arOneUserOnly); |
arUserName := Reg.ReadString('Settings', 'AR User Name', arUserName); |
Reg.Free; |
except |
end; |
finalization |
try |
Reg := TRegIniFile.Create(RegistryRoot); |
Reg.WriteString('Settings', 'Password', Password); |
Reg.WriteBool ('Settings', 'AR One User', arOneUserOnly); |
Reg.WriteString('Settings', 'AR User Name', arUserName); |
Reg.Free; |
except |
end; |
if (MapHandle <> 0) and (not FExists) then begin |
UnmapViewOfFile(MapFile); |
CloseHandle(MapHandle); |
end; |
end. |
/Delphi/akTimeLog/Source/PasswordUnit.pas |
---|
0,0 → 1,46 |
// akTimeLog v3.0 |
// Copyright (c) 1999-2000 Anatoli Klassen |
unit PasswordUnit; |
interface |
uses |
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
StdCtrls; |
type |
TPasswordForm = class(TForm) |
OkButton: TButton; |
CancelButton: TButton; |
PasswordEdit: TEdit; |
PasswordLabel: TLabel; |
procedure FormShow(Sender: TObject); |
private |
public |
function Execute : string; |
end; |
var |
PasswordForm: TPasswordForm; |
implementation |
{$R *.DFM} |
function TPasswordForm.Execute; |
begin |
PasswordEdit.Text := ''; |
Application.BringToFront; |
if ShowModal = mrOk then |
Result := PasswordEdit.Text |
else |
Result := ''; |
end; |
procedure TPasswordForm.FormShow(Sender: TObject); |
begin |
SetForegroundWindow(Handle); |
PasswordEdit.SetFocus; |
end; |
end. |
/Delphi/akTimeLog/Source/aktimelg.res |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/Delphi/akTimeLog/Source/akTimeLog.ico |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |