Tuesday, June 14, 2005

building pwlib

i have to add 729 codec support to my application. for that i downloaded voxgratia's patched version of openh323 and pwlib and started the fight for building them.
what i kept getting was some unresolved externals, so after a long, long struggle i noticed that the compiler-encoded method string which ptlib looks for for linking in ptlibd.def differs from the string in the ptlibsd.lib which is being linked.
so i decided to replace the strings in ptlibd.def with the correct ones in ptlibsd.lib. everything compiles fine so far, i wonder if it will also work fine ....

Monday, May 02, 2005

file upload with asp.net

while playing with some basic asp.net stuff i got this

Maximum request length exceeded.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Maximum request length exceeded.

Source Error:


An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:




[HttpException (0x80004005): Maximum request length exceeded.]
System.Web.HttpRequest.GetEntireRawContent() +895
System.Web.HttpRequest.GetMultipartContent() +58
System.Web.HttpRequest.FillInFormCollection() +256
System.Web.HttpRequest.get_Form() +50
System.Web.UI.Page.GetCollectionBasedOnMethod() +70
System.Web.UI.Page.DeterminePostBackMode() +47
System.Web.UI.Page.ProcessRequestMain() +42


solution was found here: simply increase HttpRuntime maxRequestLength in machine.config

But I bet you knew this already, didn't you ? :)

knoppix 3.8 and usb modems

so i decided to get a try at linux and got a knoppix cd. successfully changed the language to english (by default the cd boots in german) and wanted to browse the net. but i couldn't. rebooted to windows and started searching for a solution. after about 3 hours on almost every forum i search everybody said that it is either impossible ot very difficult to get an usb device running under linux. wtf ?
that got me even angrier so i did what i've should've done from the start: went to the source and searched the knoppix site for questions and luckily through reference from another post got to this thread:

http://www.knoppix.net/forum/viewtopic.php?p=82705
.

initially that guy's advice didn't work for me, but was great for a start.
i installed the usbnet package and as this wasn't enough i remembered having read somewhere about the tulip package and that it was somehow connected with usb devices on linux. after that i run the network card configuration and .... voila! welcome internet! :) the only remark is that for broadcast 192.168.1.255 should be used, the network card wizard came up proposing another ip...

Saturday, March 05, 2005

[Access Driver]Cannot open any more tables

I'm writing this app which reads heavilly from an access 'database'. all goes well, but after a large dataload, the odbc driver began throwing this message at me! how dare you, little woodpecker! ;)
i paniced at first and even began considering whether i should move to ADO.NET (the app is written in c#). i searched and searched the net (Google) and a note in a
message
got me startled - " ...and then close the statement object once the result set query has been accessed..." and this - "..You may also want to close the result set as you say after you are done with it...".
of course i close my datareaders and without this notion, but this constant repeating of "close this, close that" got me an idea - and then suddenly i noticed that OdbcCommand has a Dispose() method. and thats was it! after i close the datareader, now i also dispose of the odbccommand object and everything goes smoothly....

Tuesday, March 01, 2005

activex - save graphics to file

i'm writing an mfc activex control and want to save its visuals to a file. so how should i do this? the graphics on the control are created through GDI+, so should i go through Graphics contents to an Image, or may be through CDC?

so far i have this:

CDC* pdc = GetDC();

RECT rect;
GetClientRect(&rect);

Graphics graphics(pdc->GetSafeHdc());
Bitmap bitmap(rect.right -
rect.left, rect.bottom -
rect.top, &graphics);

CLSID pngClsid;
GetEncoderClsid(L"image/jpeg", &pngClsid);


bitmap.Save(fineName, &pngClsid, NULL);


but it just outputs a black screen, which is understandable

luckily my search led me to GdipCreateBitmapFromGraphics method and this post:
http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=37541&lngWId=1

where this guy - "Avery" - gives a great hint: it turns out creating the Image this way only gives a blank Image compatible with the Graphics object. to get the visuals all the graphics have to be done on a Graphics object derived from this Image. so i rewrote my drawing procedure to a function to be called with a Graphics object and depending on what i want - i would pass either the Graphics derived from the CDC in OnDraw, or the one needed for saving the image to a file... voila!

Sunday, February 27, 2005

openh323.ocx

i'm implementing a VoIP module for a client and found a very usefull atl control over the great OpenH323 opensource project.
the problems is damian's control doesnt work with a gatekeeper. after much struggle, goolgle searches and code studying, i think i found a solution:
i turns out damian's control doesn't properly initialize its endpoint, thus failing to register the gatekeeper.
so the fix is:
modify MyH323EndPoint's Initialise() method like this -


BOOL MyH323EndPoint::Initialise()
{
noFastStart = FALSE;
InitialiseCodecs();
return StartListener("*");
//original version goes like this: return TRUE;
}


thats it. now the end point properly starts its listeners and you can use a gatekeeper for PC-Phone calls

Saturday, January 15, 2005

delegates in java

so, this c# project that i have to convert to java uses delegates. i hadn't worked with delegates in c# before, so studying the delegates usage in the project was quite interesting. after some research i decide not to use reflection or anything else as a means to implement delegates in java. instead i take a to rewrite the code that uses delegates to simple function calls constructs. delegates here are used to make a templates approach to some tasks - for example visit a hierarchy of objects each of which may have subhierarchy and so on. with delegates used it makes it easy to go down the tree of objects and apply some operation on each of them AND - what is important -the operation would be a delegate so many operations can be executed by calling a single method that traverses the tree. or sort of :)
so my decision - as i cant use template code - is to generally make a tree traversal in a distinct method for each operation.
so instead of

internal override void visitHierarchy(CollectionVisitor visitor)
{
base.visitHierarchy(visitor);

foreach (SomeObject Obj in collection1)
Obj.visitHierarchy(visitor);
foreach (SomeObject Obj in collection2)
Obj.visitHierarchy(visitor);
}

there will be a similar block of code, but implemented for the different operations that need to be executed:

public void visitWithOperation1()
{
super.visitWithOperation1();

foreach (SomeObject Obj in collection1)
Obj.visitWithOperation1();
foreach (SomeObject Obj in collection2)
Obj.visitWithOperation1();
}

and

public void visitWithOperation2()
{
super.visitWithOperation2();

foreach (SomeObject Obj in collection1)
Obj.visitWithOperation2();
foreach (SomeObject Obj in collection2)
Obj.visitWithOperation2();
}


of course there isn't foreach in java... but hope you get the idea....
so this is a little bit tedious approach to rewriting delegates in java, but i hope it works for now