~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbms/src/cslib/CSS3Protocol.h

Merge Joe, plus I updated the tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef __CSS3PROTOCOL_H__
2
2
#define __CSS3PROTOCOL_H__
3
 
/* Copyright (C) 2009 PrimeBase Technologies GmbH, Germany
 
3
/* Copyright (c) 2009 PrimeBase Technologies GmbH, Germany
4
4
 *
5
5
 * PrimeBase Media Stream for MySQL
6
6
 *
16
16
 *
17
17
 * You should have received a copy of the GNU General Public License
18
18
 * along with this program; if not, write to the Free Software
19
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
19
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
20
 *
21
21
 *  Created by Barry Leslie on 10/02/09.
22
22
 *
23
23
 */
24
24
 
25
25
#include "CSHTTPStream.h"
26
 
#include "CSMd5.h"
27
26
class S3ProtocolCon;
28
27
 
29
28
#define PUB_KEY_BIT             ((uint8_t)1)
31
30
#define SERVER_BIT              ((uint8_t)4)
32
31
 
33
32
 
34
 
typedef struct S3Range {
35
 
         off64_t startByte;
36
 
         off64_t endByte;
37
 
} S3RangeRec, *S3RangePtr;
38
 
 
39
33
class CSS3Protocol: public CSRefObject {
40
34
        private:
41
35
        
45
39
        CSString *s3_private_key;
46
40
        
47
41
        uint8_t s3_ready; // A flag to indicate if the S3 protocol has been fully initialised.
48
 
        uint32_t s3_maxRetries; 
49
 
        uint32_t s3_sleepTime; 
 
42
        uint32_t s3_maxRetrys; 
50
43
        
51
44
        CSString *s3_getSignature(const char *verb, 
52
45
                                                                const char *md5, 
102
95
                }
103
96
        }
104
97
 
105
 
        void s3_setMaxRetries(uint32_t retries){s3_maxRetries = retries;}
106
 
        void s3_setSleepTime(uint32_t nap_time){s3_sleepTime = nap_time;}
107
 
        
108
98
        const char *s3_getPrivateKey() { return s3_private_key->getCString();}
109
99
        
110
100
        bool s3_isReady() { return ((s3_ready & SERVER_BIT) && (s3_ready & PUB_KEY_BIT) && (s3_ready & PRIV_KEY_BIT));}
115
105
        CSVector *s3_send(CSInputStream *input, const char *bucket, const char *key, off64_t size, const char *content_type = NULL, Md5Digest *digest = NULL, const char *s3Authorization = NULL, time_t s3AuthorizationTime = 0);
116
106
 
117
107
        // s3_receive() returns false if the object was not found.
118
 
        // If 'output' is NULL then only the headers will be fetched.
119
 
        CSVector *s3_receive(CSOutputStream *output, const char *bucket, const char *key, bool *found, S3RangePtr range = NULL, time_t *last_modified = NULL);
 
108
        CSVector *s3_receive(CSOutputStream *output, const char *bucket, const char *key, bool *found);
120
109
 
121
110
        // s3_delete() returns false if the object was not found.
122
111
        bool s3_delete(const char *bucket, const char *key);