+static gpointer s3store_new()
+{
+ S3Store *store = g_new(S3Store, 1);
+ store->thread_pool = g_thread_pool_new(s3store_task, store, -1, FALSE,
+ NULL);
+ store->bucket.bucketName = "mvrable-bluesky";
+ store->bucket.protocol = S3ProtocolHTTP;
+ store->bucket.uriStyle = S3UriStylePath;
+ store->bucket.accessKeyId = getenv("AWS_ACCESS_KEY_ID");
+ store->bucket.secretAccessKey = getenv("AWS_SECRET_ACCESS_KEY");
+
+ const char *key = getenv("BLUESKY_KEY");
+ if (key == NULL) {
+ g_error("Encryption key not defined; please set BLUESKY_KEY environment variable");
+ exit(1);
+ }
+
+ bluesky_crypt_hash_key(key, store->encryption_key);
+
+ g_print("Initializing S3 with bucket %s, access key %s, encryption key %s\n",
+ store->bucket.bucketName, store->bucket.accessKeyId, key);
+
+ return store;
+}
+
+static void s3store_destroy(gpointer store)
+{
+ g_free(store);
+}
+
+static void s3store_submit(gpointer s, BlueSkyStoreAsync *async)
+{
+ S3Store *store = (S3Store *)s;
+ g_return_if_fail(async->status == ASYNC_NEW);
+ g_return_if_fail(async->op != STORE_OP_NONE);
+
+ switch (async->op) {
+ case STORE_OP_GET:
+ case STORE_OP_PUT:
+ async->status = ASYNC_PENDING;
+ bluesky_store_async_ref(async);
+ g_thread_pool_push(store->thread_pool, async, NULL);
+ break;
+
+ default:
+ g_warning("Uknown operation type for S3Store: %d\n", async->op);
+ bluesky_store_async_mark_complete(async);
+ break;
+ }
+}
+
+static void s3store_cleanup(gpointer store, BlueSkyStoreAsync *async)
+{
+ GString *buf = (GString *)async->store_private;
+
+ if (buf != NULL) {
+ g_string_free(buf, TRUE);
+ async->store_private = NULL;
+ }