Re: Cyrus extension fixes

From: Date: Sun, 20 Jun 2004 17:43:59 +0000
Subject: Re: Cyrus extension fixes
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-869@lists.php.net to get a copy of this message
would somebody give moriyoshi access please? moriyoshi, would you be interested in taking over maintainership of this extension? -sterling Moriyoshi Koizumi wrote:
Hello, I made a huge patch for the cyrus imap extension to get it usable with the recent versions of cyrus-imapd. The patch against the HEAD of pecl/cyrus module can be downloaded from the following place: http://www.voltex.jp/patches/cyrus-misc-fixes-20040620.patch.diff.txt The attached text file briefly describes how it can be used in reality. The changes include: - Changed cyrus_query() to correctly issue imclient_processoneevent() calls until the end of the response sequence. - Changed cyrus_query() to return the status of the query instead of a simple boolean value. - Fixed cyrus_bind() to keep the php_cyrus_callback instance in the linked list associated to the resource descriptor, instead of passing one allocated in the stack frame to imclient_addcallback() as a "rock", to prevent following undesired crashes in the callback function. - Fixed memory leaks in cyrus_generic_callback(), by changing it to destroy the return value resulted from the user land callback on success. - Modified cyrus_authenticate() so it can handle password authentication without a console interaction by adding SASL callbacks. - Added two #include's to prevent warnings. - Some typo / CS fixes. Although it was one of the things I was really careing about, I'm not sure if this completely maintains backwards compatibilities. If there's no problem, please commit this one. Hope this will save someone's time. Thanks, Moriyoshi ------------------------------------------------------------------------ SYNOPSIS <!-- CREATE A MAILBOX --> <?php $cyradm_user = 'admin@localhost'; $cyradm_authname = 'admin@localhost'; $cyradm_password = 'admin'; $mbox = 'testuser'; $cyradm = cyrus_connect('localhost'); cyrus_authenticate($cyradm, "DIGEST-MD5", "imap", $cyradm_user, NULL, NULL, $cyradm_authname, $cyradm_password); $result = cyrus_query($cyradm, "CREATE user.$mbox"); if ($result === false || $result['keyword'] != 'OK') { die("Something went wrong.\n"); } print "Mailbox $mbox created successfully.\n"; ?> <!-- DROP A MAILBOX --> <?php $cyradm_user = 'admin@localhost'; $cyradm_authname = 'admin@localhost'; $cyradm_password = 'admin'; $mbox = 'testuser'; $cyradm = cyrus_connect('localhost'); cyrus_authenticate($cyradm, "DIGEST-MD5", "imap", $cyradm_user, NULL, NULL, $cyradm_authname, $cyradm_password); $result = cyrus_query($cyradm, "SETACL user.$mbox $cyradm_user c"); if ($result === false || $result['keyword'] != 'OK') { die("Something went wrong.\n"); } $result = cyrus_query($cyradm, "DELETE user.$mbox"); if ($result === false || $result['keyword'] != 'OK') { die("Something went wrong.\n"); }print "Mailbox $mbox dropped successfully.\n"; ?> <!-- RETRIEVE LIST OF MAILBOXES --> <?php $cyradm_user = 'admin@localhost'; $cyradm_authname = 'admin@localhost'; $cyradm_password = 'admin'; class cyradm_list_event_handler { var $mboxes = array(); function process_event($cyradm, $keyword, $text, $msgid) { $this->mboxes[] = $text; } } $cyradm = cyrus_connect('localhost'); cyrus_authenticate($cyradm, "DIGEST-MD5", "imap", $cyradm_user, NULL, NULL, $cyradm_authname, $cyradm_password); $hdlr = new cyradm_list_event_handler(); cyrus_bind($cyradm, array('trigger' => 'LIST', 'function' => array(&$hdlr, 'process_event'))); $result = cyrus_query($cyradm, "LIST \"\" *"); if ($result === false || $result['keyword'] != 'OK') { die("Something went wrong.\n"); } print_r($hdlr->mboxes); print "Mailboxes listed successfully.\n"; ?>


« previous php.pecl.dev (#869) next »