perl_jabber (original) (raw)
Perl Jabber Client Community
[Recent Entries][Archive][Friends][Profile]
Below are the 5 most recent journal entries recorded in the "Perl Jabber Client Community" journal:
May 23rd, 2003 | |
---|---|
_11:48 pm_[nik_w][Link] | UpdateLots of cleaning done today - removed a lot annoying passing of variables by using global variables (all tidily stored in the settings module) and changed some pointless subroutines that did nothing put return the same string everytime into variables. That all means that this ugly block of code:my socket=pjconnect::connect(socket = pj_connect::connect(socket=pjconnect::connect(server, port);myport);my port);myid = pj_connect::sendrecv($socket, pj_node::stream_start($server), 'id', pjinit::debug);pjconnect::sendrecv(pj_init::debug);pj_connect::sendrecv(pjinit::debug);pjconnect::sendrecv(socket, pj_node::iq_auth_tag($server, 'get', id,id, id,username, password,password, password,resource), '', pjinit::debug);pjconnect::sendrecv(pj_init::debug);pj_connect::sendrecv(pjinit::debug);pjconnect::sendrecv(socket, pj_node::iq_auth_tag($server, 'set', id,id, id,username, password,password, password,resource), '', pjinit::debug);pjconnect::sendrecv(pj_init::debug);pj_connect::sendrecv(pjinit::debug);pjconnect::sendrecv(socket, pj_node::get_roster(), 'roster', pjinit::debug);pjconnect::sendrecv(pj_init::debug);pj_connect::sendrecv(pjinit::debug);pjconnect::sendrecv(socket, pj_node::presence($presence), '', pjinit::debug);becomesthismuchnicerblockofcode:pj_init::debug);becomes this much nicer block of code:pjinit::debug);becomesthismuchnicerblockofcode:pj_settings::socket = pj_connect::connect;$pj_settings::id = pj_connect::sendrecv($pj_node::stream_start,'id');pj_connect::sendrecv(pj_node::iq_auth_tag('get'));pj_connect::sendrecv(pj_node::iq_auth_tag('set'));pj_connect::sendrecv($pj_node::get_roster, 'roster');pj_connect::sendrecv(pj_node::presence($presence), '');It's running very smoothly now:) Even the strange behaviour of the server that it connects to hasn't stopped me. I dunno what that was about - I could connect and authorise, but then it stopped - it wouldn't send the roster or acknowledge presence messages. I thought I might have killed something in my program, but I logged on with the windows client I use and that wouldn't work either, so I created it a new account on the funky-named jabber.atari-source.com! Current Mood: good(Leave a comment) |
_02:30 am_[nik_w][Link] | How to waste several hours on one character...£ - such a simple, everyday thing, but so hard to get working! The first problem was with character encodings - when I typed a £ into emacs, all I got was a # (which Americans seem to think is a pound sign - hence the poll in my journal). The solution to this was to tell emacs to put a £ whenever it wants to put a # by putting this line in the .emacs file: (global-set-key "\M-#" [?£]) - that was only part of the answer, though. It would write a £ to the file, but display '?'. JOe found the answer somewhere in the form of these two lines (again written to .emacs):(set-input-mode nil nil 1)(standard-display-european t)The problem with £ (like with other characters such as <,>,&,',") is that you can't put them in XML streams - they need escaping. The standard way to escape £ is by writing £, but it seems that Jabber servers don't like this at all. Instead, they would sooner you use the decimal character code (&163;) - the other option would be to do the whole unicode thing (the client I use sends a pound sign as "£"), but I'd sooner avoid that for now.In other news, I've added a couple of new (and fairly unusual) features. The first is the ability to send raw XML messages. Other clients seem to do this, and I guess it can be useful, so I figured I might as well put it in as it was easy enough to do. The second is the ability to pretend to be offline - i.e. it sends the same message out that the server sends for you when you log off. I guess it's equivalent to an invisible mode - you can see who is online, but they can't see you. You don't actually get disconnected, either - the connection to the server can be viewed on three levels:Level 1: You are in contact with the server but are not authenticated (only possible when in the process of connecting).Level 2: You are connected and authenticated, but you are not online as far as the world is concernedLevel 3: You are online (regardless of your actual status - i.e. away) - anyone subscribed to your presence can see you. The invisible mode drops you from level 3 to level 2 - changing your presence will restore you to level 3. I've also rearranged the code quite a lot - there are now 5 modules, one of which is purely a list of settings (server, username, password, etc) - this is good as it allows the user to configure the client without seeing any code - these are all accessed as global variables where needed - much better than having to pass the variables through a chain of subroutines that don't need it themselves but a deeper subroutine does. A few of these "chains" do still exist, but I've removed most of them - the rest I'll do tomorrow. I've also made a vague start at message processing - I put in a thing to tell me when someone sends me a message - now I just have to add a few regexps to actually pluck the message and sender out and display it. I need to move some code from one module to another, too, as it doesn't really belong where it is now - I think that's enough of a to-do list to occupy me for most of tomorrow, so I shall head off to bed! Current Mood: accomplished(2 comments | Leave a comment) |
May 16th, 2003 | |
_11:22 am_[nik_w][Link] | Nothing to reportProgress is at a halt at the moment, as draxil has been fiddling with his network and has yet to reconfigure his gateway to allow outside access (I should also be revising for my next exam). I tried to make my program run on cygwin, but the fork makes it explode and dump the core. Not sure why... In the meantime, I've created a few syndicated journals that have some relation to this project over the last few months, so I'll put a list here in case any of you feel like adding them to your friends page...jabber_journal - a bi-weekly report on all the latest jabber-related stuffjabber_news - lots of news and happenings regarding jabberoreilly_xml - syndication of http://www.xml.com - lots of XML related newsperl_dot_com - syndication of http://www.perl.com - lots of Perl related news Current Mood: awake(Leave a comment) |
May 15th, 2003 | |
_01:15 am_[nik_w][Link] | Help!I've just been working on escaping and unescaping HTML in messages. i.e. when you try to send < it should get turned into <. I've got quite a few characters escaped, but I'm having trouble with £. The problem is that if I press £ the terminal just beeps at me. I tried pasting it in, but that doesn't work either. Linux just doesn't seem to understand pound signs. When I send a £ from my computer to the program, it comes through as £, but I can't copy+paste that either or it just beeps. Pretty much every special character I send comes out as  followed by some random symbol. What am I doing wrong? Current Mood: confused(Leave a comment) |
May 14th, 2003 | |
_03:43 pm_[nik_w][Link] | Excitement!With some cunning use of fork, when run, my program now connects to the server, authenticates, comes online and then gives you a prompt. This prompt lets you send messages, change your presence (online/away/whatever you like), and quit. As well as this, the program will now quit when you ask it to (no more having to CTRL-C it) and even cleans up after itself by nuking the child process before it goes. I still need to figure out the whole signal catching thing. I want to catch CTRL-C so that I can kill the child process before bailing out, but wherever I put the signal catching bit, it runs the shutdown routine straight away instead of waiting for a signal. If anyone knows anything much about signal catching in perl, let me know!! Current Mood: accomplished(Leave a comment) |