Changes in uspace/lib/c/generic/clipboard.c [79ae36dd:007e6efa] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/clipboard.c
r79ae36dd r007e6efa 39 39 40 40 #include <clipboard.h> 41 #include < ns.h>41 #include <ipc/ns.h> 42 42 #include <ipc/services.h> 43 43 #include <ipc/clipboard.h> 44 #include <fibril_synch.h>45 44 #include <async.h> 46 45 #include <str.h> … … 48 47 #include <malloc.h> 49 48 50 static FIBRIL_MUTEX_INITIALIZE(clip_mutex); 51 static async_sess_t *clip_sess = NULL; 49 static int clip_phone = -1; 52 50 53 /** Start an async exchange on the clipboard session. 54 * 55 * @return New exchange. 51 /** Connect to clipboard server 56 52 * 57 53 */ 58 static async_exch_t *clip_exchange_begin(void)54 static void clip_connect(void) 59 55 { 60 fibril_mutex_lock(&clip_mutex); 61 62 while (clip_sess == NULL) 63 clip_sess = service_connect_blocking(EXCHANGE_SERIALIZE, 64 SERVICE_CLIPBOARD, 0, 0); 65 66 fibril_mutex_unlock(&clip_mutex); 67 68 return async_exchange_begin(clip_sess); 69 } 70 71 /** Finish an async exchange on the clipboard session. 72 * 73 * @param exch Exchange to be finished. 74 * 75 */ 76 static void clip_exchange_end(async_exch_t *exch) 77 { 78 async_exchange_end(exch); 56 while (clip_phone < 0) 57 clip_phone = service_connect_blocking(SERVICE_CLIPBOARD, 0, 0); 79 58 } 80 59 … … 94 73 95 74 if (size == 0) { 96 async_exch_t *exch = clip_exchange_begin(); 97 sysarg_t rc = async_req_1_0(exch, CLIPBOARD_PUT_DATA, 98 CLIPBOARD_TAG_NONE); 99 clip_exchange_end(exch); 75 async_serialize_start(); 76 clip_connect(); 77 78 sysarg_t rc = async_req_1_0(clip_phone, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_NONE); 79 80 async_serialize_end(); 100 81 101 82 return (int) rc; 102 83 } else { 103 async_exch_t *exch = clip_exchange_begin(); 104 aid_t req = async_send_1(exch, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_DATA, 105 NULL); 106 sysarg_t rc = async_data_write_start(exch, (void *) str, size); 107 clip_exchange_end(exch); 84 async_serialize_start(); 85 clip_connect(); 108 86 87 aid_t req = async_send_1(clip_phone, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_DATA, NULL); 88 sysarg_t rc = async_data_write_start(clip_phone, (void *) str, size); 109 89 if (rc != EOK) { 110 90 sysarg_t rc_orig; 111 91 async_wait_for(req, &rc_orig); 92 async_serialize_end(); 112 93 if (rc_orig == EOK) 113 94 return (int) rc; … … 117 98 118 99 async_wait_for(req, &rc); 100 async_serialize_end(); 119 101 120 102 return (int) rc; … … 135 117 /* Loop until clipboard read succesful */ 136 118 while (true) { 137 async_exch_t *exch = clip_exchange_begin(); 119 async_serialize_start(); 120 clip_connect(); 138 121 139 122 sysarg_t size; 140 123 sysarg_t tag; 141 sysarg_t rc = async_req_0_2( exch, CLIPBOARD_CONTENT, &size, &tag);124 sysarg_t rc = async_req_0_2(clip_phone, CLIPBOARD_CONTENT, &size, &tag); 142 125 143 clip_exchange_end(exch);126 async_serialize_end(); 144 127 145 128 if (rc != EOK) … … 162 145 return ENOMEM; 163 146 164 exch = clip_exchange_begin(); 165 aid_t req = async_send_1(exch, CLIPBOARD_GET_DATA, tag, NULL); 166 rc = async_data_read_start(exch, (void *) sbuf, size); 167 clip_exchange_end(exch); 147 async_serialize_start(); 168 148 149 aid_t req = async_send_1(clip_phone, CLIPBOARD_GET_DATA, tag, NULL); 150 rc = async_data_read_start(clip_phone, (void *) sbuf, size); 169 151 if ((int) rc == EOVERFLOW) { 170 152 /* … … 172 154 * the last call of CLIPBOARD_CONTENT 173 155 */ 156 async_serialize_end(); 174 157 break; 175 158 } … … 178 161 sysarg_t rc_orig; 179 162 async_wait_for(req, &rc_orig); 163 async_serialize_end(); 180 164 if (rc_orig == EOK) 181 165 return (int) rc; … … 185 169 186 170 async_wait_for(req, &rc); 171 async_serialize_end(); 187 172 188 173 if (rc == EOK) {
Note:
See TracChangeset
for help on using the changeset viewer.