From: John Graham-C. <jgr...@us...> - 2005-04-07 19:55:35
|
Update of /cvsroot/popfile/engine/Services In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21537/Services Modified Files: IMAP.pm Log Message: More work on v0.23.0 (Multi-user Support) Add account association and allow different users to log in. Users can be associated with specific accounts when POPFile is in multi-user mode. Currently every user has a blank password. Also cloning of per-bucket parameters is not working. Would love to have volunteers to do the following: 1. Test out the new functionality for account association 2. Write code to do per-bucket parameter cloning (see Bayes.pm TODO) 3. Write code to set/reset user passwords. --- Classifer/Bayes.pm: Add functions for handling account creation and deletion and mapping of accounts to users. Add new message called CREAT used to pass a child generated session to the parent. Proxy/Proxy.pm Proxy/POP3.pm: Add code for handling users associated with accounts and use it in the POP3 module to lookup users dynamically when they are logged in. UI/HTML.pm: Update UI to be able to handle different users using the cookie and changes to the History API. Add code to the users_page to handle account association on a per user basis. UI/HTTP.pm: Add url_decode_ and decode form parameters. POPFile/MQ.pm: Comment the CREAT message. POPFile/History.pm: Make history mechanism aware of different users so that different users get a different view of the history. skins/default/user_page.thtml: Add code for handling account association. languages/English.msg: Additional strings needed for the account handling. --- Once this is all working we can start to fix the test suite and nail down the v0.23.0 release. Index: IMAP.pm =================================================================== RCS file: /cvsroot/popfile/engine/Services/IMAP.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** IMAP.pm 16 Mar 2005 22:03:48 -0000 1.17 --- IMAP.pm 7 Apr 2005 19:54:48 -0000 1.18 *************** *** 9,13 **** # IMAP.pm --- a module to use POPFile for an IMAP connection. # ! # Copyright (c) 2001-2004 John Graham-Cumming # # This file is part of POPFile --- 9,13 ---- # IMAP.pm --- a module to use POPFile for an IMAP connection. # ! # Copyright (c) 2001-2005 John Graham-Cumming # # This file is part of POPFile *************** *** 225,235 **** # Check to see if we have obtained a session key yet if ( $self->{api_session__} eq '' ) { ! $self->{api_session__} = $self->classifier_()->get_session_key( 'admin', '' ); } ! # Since say__() as well as get_response__() can throw an exception, i.e. die if ! # they detect a lost connection, we eval the following code to be able ! # to catch the exception. We also tell Perl to ignore broken pipes. eval { --- 225,237 ---- # Check to see if we have obtained a session key yet + if ( $self->{api_session__} eq '' ) { ! $self->{api_session__} = $self->classifier_()->get_administrator_session_key(); } ! # Since say__() as well as get_response__() can throw an ! # exception, i.e. die if they detect a lost connection, we ! # eval the following code to be able to catch the ! # exception. We also tell Perl to ignore broken pipes. eval { *************** *** 268,282 **** --- 270,291 ---- # Reset the hash containing the hash values we have just seen. + $self->{hash_values__} = (); } }; + # if an exception occurred, we try to catch it here + if ( $@ ) { + # say__() and get_response__() will die with this message: + if ( $@ =~ /The connection to the IMAP server was lost/ ) { $self->log_( 0, $@ ); } + # If we didn't die but somebody else did, we have empathy. + else { die $@; *************** *** 318,325 **** $self->log_( 1, "Building list of serviced folders." ); ! # At this point, we simply reset the folders hash. ! # This isn't really elegant because it will leave dangling connections ! # if we have already been connected. But I trust in Perl's garbage collection ! # and keep my fingers crossed. %{$self->{folders__}} = (); --- 327,334 ---- $self->log_( 1, "Building list of serviced folders." ); ! # At this point, we simply reset the folders hash. This isn't ! # really elegant because it will leave dangling connections if we ! # have already been connected. But I trust in Perl's garbage ! # collection and keep my fingers crossed. %{$self->{folders__}} = (); *************** *** 340,347 **** } ! # If this is a new POPFile installation that isn't yet ! # configured, our hash will have exactly one key now ! # which will point to the INBOX. Since this isn't enough ! # to do anything meaningful, we simply reset the hash: if ( ( keys %{$self->{folders__}} ) == 1 ) { --- 349,356 ---- } ! # If this is a new POPFile installation that isn't yet configured, ! # our hash will have exactly one key now which will point to the ! # INBOX. Since this isn't enough to do anything meaningful, we ! # simply reset the hash: if ( ( keys %{$self->{folders__}} ) == 1 ) { *************** *** 358,365 **** # connect_folders__ # ! # This function will iterate over each folder found in the %{$self->{folders__}} ! # hash. For each folder it will try to establish a connection, log in, and select ! # the folder. ! # The corresponding socket object, will be stored in # $self->{folders__}{$folder}{imap} # --- 367,374 ---- # connect_folders__ # ! # This function will iterate over each folder found in the ! # %{$self->{folders__}} hash. For each folder it will try to ! # establish a connection, log in, and select the folder. The ! # corresponding socket object, will be stored in # $self->{folders__}{$folder}{imap} # *************** *** 471,478 **** # scan_folder # ! # This function scans a folder on the IMAP server. ! # According to the attributes of a folder (watched, output), and the attributes ! # of the message (new, classified, etc) it then decides what to do with the ! # messages. # There are currently three possible actions: # 1. Classify the message and move to output folder --- 480,487 ---- # scan_folder # ! # This function scans a folder on the IMAP server. According to the ! # attributes of a folder (watched, output), and the attributes of ! # the message (new, classified, etc) it then decides what to do with ! # the messages. # There are currently three possible actions: # 1. Classify the message and move to output folder *************** *** 584,591 **** # classify_message # ! # This function takes a message UID and then tries to classify the corresponding ! # message to a POPFile bucket. It delegates all the house-keeping that keeps ! # the POPFile statistics up to date to helper functions, but the house-keeping ! # is done. The caller need not worry about this. # # Arguments: --- 593,601 ---- # classify_message # ! # This function takes a message UID and then tries to classify the ! # corresponding message to a POPFile bucket. It delegates all the ! # house-keeping that keeps the POPFile statistics up to date to ! # helper functions, but the house-keeping is done. The caller need ! # not worry about this. # # Arguments: *************** *** 702,709 **** # reclassify_message # ! # This function takes a message UID and then tries to reclassify the corresponding ! # message from one POPFile bucket to another POPFile bucket. It delegates all the ! # house-keeping that keeps the POPFile statistics up to date to helper functions, ! # but the house-keeping # is done. The caller need not worry about this. # --- 712,719 ---- # reclassify_message # ! # This function takes a message UID and then tries to reclassify the ! # corresponding message from one POPFile bucket to another POPFile ! # bucket. It delegates all the house-keeping that keeps the POPFile ! # statistics up to date to helper functions, but the house-keeping # is done. The caller need not worry about this. # *************** *** 1103,1108 **** # raw_get_response # ! # Get a response from our server. You should normally not need to call this function ! # directly. Use get_response__ instead. # # Arguments: --- 1113,1118 ---- # raw_get_response # ! # Get a response from our server. You should normally not need to ! # call this function directly. Use get_response__ instead. # # Arguments: *************** *** 1161,1166 **** $octet_count += length $buf; ! # There doesn't seem to be a requirement for the message to end with ! # a newline. So we cannot go for equality if ( $octet_count >= $count_octets ) { --- 1171,1176 ---- $octet_count += length $buf; ! # There doesn't seem to be a requirement for the message ! # to end with a newline. So we cannot go for equality if ( $octet_count >= $count_octets ) { *************** *** 1202,1207 **** } ! # This could happen, but will be caught by the eval in service(). ! # Nevertheless, we look out for unsolicited bye-byes here. if ( $untagged_response =~ /^BYE/ && $last_command !~ /^LOGOUT/ ) { --- 1212,1218 ---- } ! # This could happen, but will be caught by the eval in ! # service(). Nevertheless, we look out for ! # unsolicited bye-byes here. if ( $untagged_response =~ /^BYE/ && $last_command !~ /^LOGOUT/ ) { *************** *** 1252,1258 **** # get_response__ # ! # Use this function to get a response from the server. The response will be stored in ! # $self->{last_response__} if you pass in a socket object or in ! # $self->{folders}{$folder}{last_response} if you pass in a folder name # # Arguments: --- 1263,1270 ---- # get_response__ # ! # Use this function to get a response from the server. The response ! # will be stored in $self->{last_response__} if you pass in a socket ! # object or in $self->{folders}{$folder}{last_response} if you pass in ! # a folder name # # Arguments: *************** *** 1318,1323 **** # get_mailbox_list # ! # Request a list of mailboxes from the server behind the passed in socket object. ! # The list is stored away in @{$self->{mailboxes__}} and returned. # # Arguments: --- 1330,1336 ---- # get_mailbox_list # ! # Request a list of mailboxes from the server behind the passed in ! # socket object. The list is stored away in @{$self->{mailboxes__}} ! # and returned. # # Arguments: |