Archive

Archive for the ‘Delphi stuff’ Category

MySolusVM 0.5 beta

October 10th, 2011 No comments

Published a new version of my SolusVM client application.

New version supports multiple servers, displays warnings upon an error and there is also a 64-bit version available.

Categories: Delphi stuff, Software Tags:

TwitterLib and TwitMee update

March 31st, 2011 4 comments

Updated my delphi twitter library and the little twitme tool.

There was a problem with the unix timestamp related to daylight savings time which just recently started here.

[download#7#format=2]
[download#7#format=1]

Categories: Delphi stuff, Software Tags:

Twitter library v0.33

March 5th, 2011 No comments

New version of my Twitter library for Delphi.

– xAuth/SSL support.

There are several changes in the login process, please read the usage.pas and changelog.

[download#7#format=2]
[download#7#format=1]

Twitter library update 0.32

February 28th, 2011 No comments

[download#7#format=2]
[download#7#format=1]

Categories: Delphi stuff, Software Tags:

another twitter library update v0.31

February 27th, 2011 1 comment

v0.3:

– Added a method: RetrievePIN(user,pass), with this you can avoid the user having to login and return with an access PIN, the app will retrieve it on its own by simulating a login etc. Use with care, since this method is prone to errors whenever Twitter changes something in their login and auth process. Check usage.pas for details on when to use this.
Note: reposted with a small modification to fix an error in the preauth process, redownload if you got 0.3 before.

[download#7#format=2]
[download#7#format=1]

Here’s the magic:

001procedure TwitterCli.RetrievePIN(user,pass: ansistring);
002Var h: THttpCli;
003    pvars,token,oatoken: ansistring;
004    ts: TStringList;
005    s,x: ansistring;
006    a: Integer;
007begin
008 
009  LastReq := trRequestRawAccess;
010 
011  FCookie := '';
012  ts := TStringList.Create;
013  h := THttpCli.Create(nil);
014  with h do
015  begin
016    url := 'http://twitter.com/oauth/authorize?oauth_token='+OAuthToken;
017    RcvdStream := TMemoryStream.Create;
018    OnDocEnd           := HTTPClientDocEnd;
019    OnHeaderEnd        := HTTPClientHeaderEnd;
020    OnBeforeHeaderSend := HTTPClientBeforeHeaderSend;
021    OnCookie           := GrabCookie;
022    try
023      Get;
024    except
025      on e:exception do
026      begin
027        if DebugMode then if Assigned(DebugMemo) then TMemo(DebugMemo).Lines.Add(e.Message);
028        ResultStrings.Text := 'Error: '+e.Message;
029      end;
030    end;
031 
032     try
033      h.RcvdStream.WriteBuffer(#0' ', 1);
034      h.RcvdStream.Position := 0;
035      ts.LoadFromStream(h.RcvdStream);
036    finally
037    end;
038  end;
039 
040  if h.StatusCode <> 200 then
041  begin
042    LastHttpStatus := h.StatusCode;
043    ResultStrings.Text := 'Error in raw authentication on 1st step';
044    h.RcvdStream.Free; h.RcvdStream := nil;
045    FreeAndNil(h);
046    FreeAndNil(ts);
047    TriggerReqDone;
048    Exit;
049  end;
050 
051 
052  if DebugMode then if Assigned(DebugMemo) then with TMemo(DebugMemo) do
053   TMemo(DebugMemo).Lines.Add(h.Cookie);
054 
055    h.RcvdStream.Free; h.RcvdStream := nil;
056 
057  if FCookie[length(FCookie)] = ';' then Delete(FCookie,length(FCookie),1);
058 
059  if DebugMode then if Assigned(DebugMemo) then with TMemo(DebugMemo) do
060  begin
061    TMemo(DebugMemo).Lines.Add('----------------------------------------');
062    TMemo(DebugMemo).Lines.Add('----------------------------------------');
063  end;
064 
065  s := ts.text;
066  if Pos('twttr.form_authenticity_token', s) > 0 then
067  begin
068    Delete(s,1,Pos('twttr.form_authenticity_token',s)+32);
069    s := Copy(s,1,Pos('''',s)-1);
070  end
071  else
072  begin
073    LastHttpStatus := 0;
074    ResultStrings.Text := 'Error in raw authentication prelogin';
075    h.RcvdStream.Free; h.RcvdStream := nil;
076    FreeAndNil(h);
077    FreeAndNil(ts);
078    TriggerReqDone;
079    Exit;
080  end;
081 
082  ts.Clear;
083  with h do
084  begin
085    url := 'http://twitter.com/oauth/authorize';
086    RcvdStream := TMemoryStream.Create;
087    SendStream := TMemoryStream.Create;
088    pvars := ('authenticity_token=' + s +
089             '&oauth_token=' + OAuthToken +
090             '&session%5Busername_or_email%5D=' + user +
091             '&session%5Bpassword%5D=' + pass);
092    SendStream.Write(pvars[1], Length(pvars));
093    SendStream.Seek(0, soFromBeginning);
094    OnDocEnd           := HTTPClientDocEnd;
095    OnHeaderEnd        := HTTPClientHeaderEnd;
096    OnBeforeHeaderSend := HTTPClientBeforeHeaderSend;
097    Cookie := FCookie;
098    if DebugMode then if Assigned(DebugMemo) then with TMemo(DebugMemo) do
099     TMemo(DebugMemo).Lines.Add('Cookie before post='+FCookie);
100    ExtraHeader := 'Origin:https://twitter.com' + #13#10 +
101                   'Referer:http://twitter.com/oauth/authorize?oauth_token=' + OAuthToken;
102    try
103      Post;
104    except
105      on e:exception do
106      begin
107        if DebugMode then if Assigned(DebugMemo) then TMemo(DebugMemo).Lines.Add(e.Message);
108        ResultStrings.Text := 'Error: '+e.Message;
109      end;
110    end;
111 
112     try
113      h.RcvdStream.WriteBuffer(#0' ', 1);
114      h.RcvdStream.Position := 0;
115      ts.LoadFromStream(h.RcvdStream);
116    finally
117    end;
118 
119    x := '';
120    s := ts.Text;
121    if Pos('<div id="oauth_pin">',s) > 0 then
122    begin
123      Delete(s,1,Pos('<div id="oauth_pin">',s)+19);
124      s := Copy(s,1,Pos('<',s));
125      for a := 1 to length(s) do
126       if (Ord(s&#91;a&#93;) > 47) and (Ord(s[a]) < 58) then
127        x := x + s&#91;a&#93;;
128    end;
129 
130    LastHttpStatus := h.StatusCode;
131 
132    if x = '' then LastHttpStatus := 0
133    else AccessPIN := x;
134 
135    if DebugMode then if Assigned(DebugMemo) then TMemo(DebugMemo).Lines.Add('PIN='+x);
136 
137    if DebugMode then if Assigned(DebugMemo) then with TMemo(DebugMemo) do
138    begin
139      TMemo(DebugMemo).Lines.Add(ts.Text);
140      TMemo(DebugMemo).Lines.Add(h.Cookie);
141    end;
142 
143    if h.StatusCode <> 200 then ResultStrings.Text := 'Error in raw authentication on 2nd step';
144 
145    FreeAndNil(ts);
146    h.RcvdStream.Free; h.RcvdStream := nil;
147    h.SendStream.Free; h.SendStream := nil;
148    FreeAndNil(h);
149  end;
150 
151  TriggerReqDone;
152 
153end;
154 
155procedure TwitterCli.GrabCookie(Sender: TObject; const Data: string; var Accept: Boolean);
156begin
157  FCookie := FCookie + Data + ';';
158end;
Categories: Delphi stuff, Software Tags:

twitter library update

February 27th, 2011 No comments

Slightly modified my delphi twitter library to work with the latest ICS distribution and to remove the dependency of an altered OverbyteIcsHttpProt file.

[download#7#format=2]
[download#7#format=1]

Categories: Delphi stuff, Software Tags:

Twitter library for Delphi

February 27th, 2011 45 comments

2013 fix/update: http://code.google.com/p/delphi-twitter-library/

Edit: As of December 2012 Twitter api is using GZip in every callback, so you’ll have to enable content encoding before every Get/Post call, and then load the result from a gzipped stream in the RequestDone procs.

Edit June 2012: This twitter library is now deprecated and will no longer be updated. I’ve rewritten it as a generic OAuth lib to use with both Twitter and Imgur (and any other OAuth 1.0 services) for a closed source project.

This is my take on Open Auth and Twitter for Delphi. I recently had to look into it to update a twitter plugin for my Mal Upater application, so I made this small library along with a test application TwitMee. There is barely nothing at all for Delphi, and the little
I found was overcomplicated and didn’t work with Unicode (f.e. japanese symbols etc) (my library does).

I’ve been asked by a few people to make it open source, so here’s the code, use it freely as long you comply with the GPL v3 license.

Requirements: one of the latest versions of Delphi which includes Unicode. (probably easy to adapt using Jedi’s jcl implementation
for unicode strings as well).

Read more…

Categories: Delphi stuff, Software Tags:

Tokyo Expose 0.1

May 19th, 2008 No comments

Tokyo Expose 0.1 / May 19 2008

Little application to somewhat simulate the Mac/Linux(KDE?) effect that shows live thumbnails of all open applications on screen. The thumbnails update in real time and light up when you hover the mouse over.

Simply run it; when you hover your mouse over the TOP-RIGHT corner of the screen, the expose will activate, and:
left-clicking a window = bring it up
right-clicking a window = close that program
left-clicking the desktop window = minimize all programs
ESC = cancel

To close it, click “exit” from the tray-icon menu

Requirements: Windows Vista 32/64 bits

Download: http://techsuki.net/apps/TokyoExpose/TokyoExpose.exe

tokyoexpose.jpg

Categories: Delphi stuff, Misc, Software, tehsuki import Tags:

TokyoFileSearch 0.1

May 8th, 2008 1 comment

This is a very simple and lite application to index and search for files in your hard disks. Tired of the lame and cpu-intensive file search stuff in windows I decided to make my own. It needs to be manually re-indexed when you add new files but it suits my needs.

Download: http://techsuki.net/apps/TokyoFileSearch/TokyoFileSearch.exe (322 KB)

Runs in Windows 95 to Vista, either 32 or 64 bits. Does NOT require .net
Simply download and run it somewhere. It will create a file called “index.db” when you run the indexer, in the same exe folder, don’t delete it.

Consider it a beta since there is a lot to be done, it’s very raw now.. but does its job. Check back later for updates.

Click on the pictures for a bigger screenshot.

Categories: Delphi stuff, Misc, Software, tehsuki import Tags: