Objectively
Object oriented framework for C.
Loading...
Searching...
No Matches
URLSessionTask.h
Go to the documentation of this file.
1/*
2 * Objectively: Ultra-lightweight object oriented framework for GNU C.
3 * Copyright (C) 2014 Jay Dolan <jay@jaydolan.com>
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source distribution.
22 */
23
24#pragma once
25
26#include <Objectively/Object.h>
27#include <Objectively/Thread.h>
28
34typedef struct URLSessionTask URLSessionTask;
35typedef struct URLSessionTaskInterface URLSessionTaskInterface;
36
42
48typedef void (*URLSessionTaskCompletion)(URLSessionTask *task, bool success);
49
62
69
74
79 URLSessionTaskInterface *interface[0];
80
85
90
95
99 size_t bytesSent;
100
105
110
114 char *error;
115
120 ident handle;
121
127 bool isExecuting;
128
133
138
143 ident requestHeaders;
144
149
156
164
169};
170
174struct URLSessionTaskInterface {
175
179 ObjectInterface objectInterface;
180
190 void (*cancel)(URLSessionTask *self);
191
200 void (*execute)(URLSessionTask *self);
201
212 URLSessionTask *(*initWithRequestInSession)(URLSessionTask *self, struct URLRequest *request,
213 struct URLSession *session, URLSessionTaskCompletion completion);
214
221 void (*resume)(URLSessionTask *self);
222
230 void (*setup)(URLSessionTask *self);
231
238 void (*suspend)(URLSessionTask *self);
239
247 void (*teardown)(URLSessionTask *self);
248};
249
static void teardown(void)
Called atexit to teardown Objectively.
Definition Class.c:76
static void setup(void)
Called when initializing Object to setup Objectively.
Definition Class.c:113
Object is the root Class of The Objectively Class hierarchy.
static void resume(OperationQueue *self)
static void suspend(OperationQueue *self)
static int request(RESTClient *self, HTTPMethod method, const char *url_string, const Data *body, const char **headers, Data **out_data)
Definition RESTClient.c:62
POSIX Threads.
void * ident
The identity type, similar to Objective-C id.
Definition Types.h:49
#define OBJECTIVELY_EXPORT
Definition Types.h:36
OBJECTIVELY_EXPORT Class * _URLSessionTask(void)
void(* URLSessionTaskCompletion)(URLSessionTask *task, bool success)
A function pointer for URLSessionTask completion.
void(* URLSessionTaskProgress)(URLSessionTask *task)
A function pointer for URLSessionTask progress.
URLSessionTaskState
The various states a URLSessionTask may be in.
@ URLSESSIONTASK_RESUMING
@ URLSESSIONTASK_CANCELED
@ URLSESSIONTASK_SUSPENDING
@ URLSESSIONTASK_SUSPENDED
@ URLSESSIONTASK_COMPLETED
@ URLSESSIONTASK_RESUMED
@ URLSESSIONTASK_CANCELING
The runtime representation of a Class.
Definition Class.h:90
Object is the root Class of The Objectively Class hierarchy.
Definition Object.h:46
A protocol-agnostic abstraction for requesting resources via URLs.
Definition URLRequest.h:58
A protocol-agnostic abstraction for URLSessionTask responses.
Definition URLResponse.h:42
A management context for loading resources via URLs.
Definition URLSession.h:59
URL session tasks are handles to pending URL operations.
struct URLResponse * response
The response.
URLSessionTaskProgress progress
The progress function.
int result
The libcurl result code (CURLcode) of the transfer, 0 on success.
size_t bytesExpectedToSend
The count of bytes this task expects to send.
ident data
User data.
Object object
The superclass.
char * error
The error buffer.
struct URLRequest * request
The request.
size_t bytesReceived
The count of bytes received.
struct URLSession * session
The session, which is not retained.
URLSessionTaskState state
The state.
URLSessionTaskCompletion completion
The completion function.
size_t bytesSent
The count of bytes sent.
URLSessionTaskInterface * interface[0]
The interface type.
size_t bytesExpectedToReceive
The count of bytes this task expects to receive.