| 1 |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- |
| 2 |
* |
| 3 |
* Copyright (C) 2009 Richard Hughes <[email protected]> |
| 4 |
* |
| 5 |
* Licensed under the GNU Lesser General Public License Version 2.1 |
| 6 |
* |
| 7 |
* This library is free software; you can redistribute it and/or |
| 8 |
* modify it under the terms of the GNU Lesser General Public |
| 9 |
* License as published by the Free Software Foundation; either |
| 10 |
* version 2.1 of the License, or (at your option) any later version. |
| 11 |
* |
| 12 |
* This library is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
* Lesser General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU Lesser General Public |
| 18 |
* License along with this library; if not, write to the Free Software |
| 19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 |
*/ |
| 21 |
|
| 22 |
/** |
| 23 |
* SECTION:pk-progress |
| 24 |
* @short_description: Transaction progress information |
| 25 |
* |
| 26 |
* This GObject is available to clients to be able to query details about |
| 27 |
* the transaction. All of the details on this object are stored as properties. |
| 28 |
*/ |
| 29 |
|
| 30 |
#include "config.h" |
| 31 |
|
| 32 |
#include <packagekit-glib2/pk-enum.h> |
| 33 |
#include <packagekit-glib2/pk-package-id.h> |
| 34 |
#include <packagekit-glib2/pk-progress.h> |
| 35 |
#include <packagekit-glib2/pk-progress-private.h> |
| 36 |
|
| 37 |
static void pk_progress_dispose (GObject *object); |
| 38 |
static void pk_progress_finalize (GObject *object); |
| 39 |
|
| 40 |
/** |
| 41 |
* PkProgressPrivate: |
| 42 |
* |
| 43 |
* Private #PkProgress data |
| 44 |
**/ |
| 45 |
struct _PkProgressPrivate |
| 46 |
{ |
| 47 |
gchar *package_id; |
| 48 |
gchar *transaction_id; |
| 49 |
gint percentage; |
| 50 |
gboolean allow_cancel; |
| 51 |
PkRoleEnum role; |
| 52 |
PkStatusEnum status; |
| 53 |
gboolean caller_active; |
| 54 |
guint elapsed_time; |
| 55 |
guint remaining_time; |
| 56 |
guint speed; |
| 57 |
guint64 download_size_remaining; |
| 58 |
guint64 transaction_flags; |
| 59 |
guint uid; |
| 60 |
gchar *sender; |
| 61 |
PkItemProgress *item_progress; |
| 62 |
PkPackage *package; |
| 63 |
PkProgressCallback callback; |
| 64 |
gpointer callback_user_data; |
| 65 |
}; |
| 66 |
|
| 67 |
enum { |
| 68 |
PROP_0, |
| 69 |
PROP_PACKAGE_ID, |
| 70 |
PROP_TRANSACTION_ID, |
| 71 |
PROP_PERCENTAGE, |
| 72 |
PROP_ALLOW_CANCEL, |
| 73 |
PROP_ROLE, |
| 74 |
PROP_STATUS, |
| 75 |
PROP_CALLER_ACTIVE, |
| 76 |
PROP_ELAPSED_TIME, |
| 77 |
PROP_REMAINING_TIME, |
| 78 |
PROP_SPEED, |
| 79 |
PROP_DOWNLOAD_SIZE_REMAINING, |
| 80 |
PROP_TRANSACTION_FLAGS, |
| 81 |
PROP_UID, |
| 82 |
PROP_SENDER, |
| 83 |
PROP_PACKAGE, |
| 84 |
PROP_ITEM_PROGRESS, |
| 85 |
PROP_LAST |
| 86 |
}; |
| 87 |
|
| 88 |
static GParamSpec *obj_properties[PROP_LAST] = { NULL, }; |
| 89 |
|
| 90 |
G_DEFINE_TYPE_WITH_PRIVATE (PkProgress, pk_progress, G_TYPE_OBJECT) |
| 91 |
#define GET_PRIVATE(o) (pk_progress_get_instance_private (o)) |
| 92 |
|
| 93 |
/* |
| 94 |
* pk_progress_get_property: |
| 95 |
**/ |
| 96 |
static void |
| 97 |
pk_progress_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) |
| 98 |
{ |
| 99 |
PkProgress *progress = PK_PROGRESS (object); |
| 100 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 101 |
|
| 102 |
switch (prop_id) { |
| 103 |
case PROP_PACKAGE_ID: |
| 104 |
g_value_set_string (value, priv->package_id); |
| 105 |
break; |
| 106 |
case PROP_TRANSACTION_ID: |
| 107 |
g_value_set_string (value, priv->transaction_id); |
| 108 |
break; |
| 109 |
case PROP_PERCENTAGE: |
| 110 |
g_value_set_int (value, priv->percentage); |
| 111 |
break; |
| 112 |
case PROP_ITEM_PROGRESS: |
| 113 |
g_value_set_object (value, priv->item_progress); |
| 114 |
break; |
| 115 |
case PROP_ALLOW_CANCEL: |
| 116 |
g_value_set_boolean (value, priv->allow_cancel); |
| 117 |
break; |
| 118 |
case PROP_STATUS: |
| 119 |
g_value_set_uint (value, priv->status); |
| 120 |
break; |
| 121 |
case PROP_ROLE: |
| 122 |
g_value_set_uint (value, priv->role); |
| 123 |
break; |
| 124 |
case PROP_CALLER_ACTIVE: |
| 125 |
g_value_set_boolean (value, priv->caller_active); |
| 126 |
break; |
| 127 |
case PROP_ELAPSED_TIME: |
| 128 |
g_value_set_uint (value, priv->elapsed_time); |
| 129 |
break; |
| 130 |
case PROP_REMAINING_TIME: |
| 131 |
g_value_set_uint (value, priv->remaining_time); |
| 132 |
break; |
| 133 |
case PROP_SPEED: |
| 134 |
g_value_set_uint (value, priv->speed); |
| 135 |
break; |
| 136 |
case PROP_DOWNLOAD_SIZE_REMAINING: |
| 137 |
g_value_set_uint64 (value, priv->download_size_remaining); |
| 138 |
break; |
| 139 |
case PROP_TRANSACTION_FLAGS: |
| 140 |
g_value_set_uint64 (value, priv->transaction_flags); |
| 141 |
break; |
| 142 |
case PROP_UID: |
| 143 |
g_value_set_uint (value, priv->uid); |
| 144 |
break; |
| 145 |
case PROP_SENDER: |
| 146 |
g_value_set_string (value, priv->sender); |
| 147 |
break; |
| 148 |
case PROP_PACKAGE: |
| 149 |
g_value_set_object (value, priv->package); |
| 150 |
break; |
| 151 |
default: |
| 152 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
| 153 |
break; |
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
static inline void |
| 158 |
pk_progress_invoke_callback (PkProgress *progress, PkProgressType type) |
| 159 |
{ |
| 160 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 161 |
|
| 162 |
g_assert (PK_IS_PROGRESS (progress)); |
| 163 |
|
| 164 |
if (priv->callback) |
| 165 |
priv->callback (progress, type, priv->callback_user_data); |
| 166 |
} |
| 167 |
|
| 168 |
/** |
| 169 |
* pk_progress_set_package_id: |
| 170 |
* @progress: a valid #PkProgress instance |
| 171 |
* @package_id: a PackageID |
| 172 |
* |
| 173 |
* Set the package ID this transaction is acting on. |
| 174 |
* |
| 175 |
* Return value: %TRUE if value changed. |
| 176 |
* |
| 177 |
* Since: 0.5.2 |
| 178 |
**/ |
| 179 |
gboolean |
| 180 |
pk_progress_set_package_id (PkProgress *progress, const gchar *package_id) |
| 181 |
{ |
| 182 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 183 |
|
| 184 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 185 |
|
| 186 |
/* the same as before? */ |
| 187 |
if (g_strcmp0 (priv->package_id, package_id) == 0) |
| 188 |
return FALSE; |
| 189 |
|
| 190 |
/* valid? */ |
| 191 |
if (!pk_package_id_check (package_id)) { |
| 192 |
g_warning ("invalid package_id %s", package_id); |
| 193 |
return FALSE; |
| 194 |
} |
| 195 |
|
| 196 |
/* new value */ |
| 197 |
g_free (priv->package_id); |
| 198 |
priv->package_id = g_strdup (package_id); |
| 199 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_PACKAGE_ID]); |
| 200 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_PACKAGE_ID); |
| 201 |
|
| 202 |
return TRUE; |
| 203 |
} |
| 204 |
|
| 205 |
/** |
| 206 |
* pk_progress_get_package_id: |
| 207 |
* @progress: a valid #PkProgress instance |
| 208 |
* |
| 209 |
* Get the package ID this transaction is acting on. |
| 210 |
* |
| 211 |
* Return value: a PackageID |
| 212 |
* |
| 213 |
* Since: 1.0.12 |
| 214 |
**/ |
| 215 |
const gchar * |
| 216 |
pk_progress_get_package_id (PkProgress *progress) |
| 217 |
{ |
| 218 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 219 |
|
| 220 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), NULL); |
| 221 |
|
| 222 |
return priv->package_id; |
| 223 |
} |
| 224 |
|
| 225 |
/** |
| 226 |
* pk_progress_set_item_progress: |
| 227 |
* @progress: a valid #PkProgress instance |
| 228 |
* @item_progress: a #PkItemProgress |
| 229 |
* |
| 230 |
* Set the item progress associated with this transaction. |
| 231 |
* |
| 232 |
* Return value: %TRUE if value changed. |
| 233 |
* |
| 234 |
* Since: 0.8.1 |
| 235 |
**/ |
| 236 |
gboolean |
| 237 |
pk_progress_set_item_progress (PkProgress *progress, |
| 238 |
PkItemProgress *item_progress) |
| 239 |
{ |
| 240 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 241 |
|
| 242 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 243 |
|
| 244 |
if (g_set_object (&priv->item_progress, item_progress)) { |
| 245 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_ITEM_PROGRESS]); |
| 246 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_ITEM_PROGRESS); |
| 247 |
return TRUE; |
| 248 |
} |
| 249 |
|
| 250 |
return FALSE; |
| 251 |
} |
| 252 |
|
| 253 |
/** |
| 254 |
* pk_progress_get_item_progress: |
| 255 |
* @progress: a valid #PkProgress instance |
| 256 |
* |
| 257 |
* Get the item progress associated with this transaction. |
| 258 |
* |
| 259 |
* Return value: (transfer none): a #PkItemProgress |
| 260 |
* |
| 261 |
* Since: 1.0.12 |
| 262 |
**/ |
| 263 |
PkItemProgress * |
| 264 |
pk_progress_get_item_progress (PkProgress *progress) |
| 265 |
{ |
| 266 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 267 |
|
| 268 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), NULL); |
| 269 |
|
| 270 |
return priv->item_progress; |
| 271 |
} |
| 272 |
|
| 273 |
/** |
| 274 |
* pk_progress_set_transaction_id: |
| 275 |
* @progress: a valid #PkProgress instance |
| 276 |
* @transaction_id: a transaction ID. |
| 277 |
* |
| 278 |
* Set the ID used by this transaction. |
| 279 |
* |
| 280 |
* Since: 0.5.3 |
| 281 |
* |
| 282 |
* Return value: %TRUE if value changed. |
| 283 |
**/ |
| 284 |
gboolean |
| 285 |
pk_progress_set_transaction_id (PkProgress *progress, const gchar *transaction_id) |
| 286 |
{ |
| 287 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 288 |
|
| 289 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 290 |
|
| 291 |
/* the same as before? */ |
| 292 |
if (g_strcmp0 (priv->transaction_id, transaction_id) == 0) |
| 293 |
return FALSE; |
| 294 |
|
| 295 |
/* new value */ |
| 296 |
g_free (priv->transaction_id); |
| 297 |
priv->transaction_id = g_strdup (transaction_id); |
| 298 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_TRANSACTION_ID]); |
| 299 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_TRANSACTION_ID); |
| 300 |
|
| 301 |
return TRUE; |
| 302 |
} |
| 303 |
|
| 304 |
/** |
| 305 |
* pk_progress_get_transaction_id: |
| 306 |
* @progress: a valid #PkProgress instance |
| 307 |
* |
| 308 |
* Get the ID used by this transaction. |
| 309 |
* |
| 310 |
* Return value: a transaction ID. |
| 311 |
* |
| 312 |
* Since: 1.0.12 |
| 313 |
**/ |
| 314 |
const gchar * |
| 315 |
pk_progress_get_transaction_id (PkProgress *progress) |
| 316 |
{ |
| 317 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 318 |
|
| 319 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), NULL); |
| 320 |
|
| 321 |
return priv->transaction_id; |
| 322 |
} |
| 323 |
|
| 324 |
/** |
| 325 |
* pk_progress_set_percentage: |
| 326 |
* @progress: a valid #PkProgress instance |
| 327 |
* @percentage: a percentage value (0-100) |
| 328 |
* |
| 329 |
* Set the percentage complete of this transaction. |
| 330 |
* |
| 331 |
* Return value: %TRUE if value changed. |
| 332 |
* |
| 333 |
* Since: 0.5.2 |
| 334 |
**/ |
| 335 |
gboolean |
| 336 |
pk_progress_set_percentage (PkProgress *progress, gint percentage) |
| 337 |
{ |
| 338 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 339 |
|
| 340 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 341 |
|
| 342 |
/* the same as before? */ |
| 343 |
if (priv->percentage == percentage) |
| 344 |
return FALSE; |
| 345 |
|
| 346 |
/* new value */ |
| 347 |
priv->percentage = percentage; |
| 348 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_PERCENTAGE]); |
| 349 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_PERCENTAGE); |
| 350 |
|
| 351 |
return TRUE; |
| 352 |
} |
| 353 |
|
| 354 |
/** |
| 355 |
* pk_progress_get_percentage: |
| 356 |
* @progress: a valid #PkProgress instance |
| 357 |
* |
| 358 |
* Get the percentage complete. |
| 359 |
* |
| 360 |
* Return value: a percentage (0-100) |
| 361 |
* |
| 362 |
* Since: 1.0.12 |
| 363 |
**/ |
| 364 |
gint |
| 365 |
pk_progress_get_percentage (PkProgress *progress) |
| 366 |
{ |
| 367 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 368 |
|
| 369 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), -1); |
| 370 |
|
| 371 |
return priv->percentage; |
| 372 |
} |
| 373 |
|
| 374 |
/** |
| 375 |
* pk_progress_set_status: |
| 376 |
* @progress: a valid #PkProgress instance |
| 377 |
* @status: a #PkStatusEnum |
| 378 |
* |
| 379 |
* Set the status of this transaction. |
| 380 |
* |
| 381 |
* Return value: %TRUE if value changed. |
| 382 |
* |
| 383 |
* Since: 0.5.2 |
| 384 |
**/ |
| 385 |
gboolean |
| 386 |
pk_progress_set_status (PkProgress *progress, PkStatusEnum status) |
| 387 |
{ |
| 388 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 389 |
|
| 390 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 391 |
|
| 392 |
/* the same as before? */ |
| 393 |
if (priv->status == status) |
| 394 |
return FALSE; |
| 395 |
|
| 396 |
/* new value */ |
| 397 |
priv->status = status; |
| 398 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_STATUS]); |
| 399 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_STATUS); |
| 400 |
|
| 401 |
return TRUE; |
| 402 |
} |
| 403 |
|
| 404 |
/** |
| 405 |
* pk_progress_get_status: |
| 406 |
* @progress: a valid #PkProgress instance |
| 407 |
* |
| 408 |
* Get the status of this transaction. |
| 409 |
* |
| 410 |
* Return value: a status string |
| 411 |
* |
| 412 |
* Since: 1.0.12 |
| 413 |
**/ |
| 414 |
PkStatusEnum |
| 415 |
pk_progress_get_status (PkProgress *progress) |
| 416 |
{ |
| 417 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 418 |
|
| 419 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), PK_STATUS_ENUM_UNKNOWN); |
| 420 |
|
| 421 |
return priv->status; |
| 422 |
} |
| 423 |
|
| 424 |
/** |
| 425 |
* pk_progress_set_role: |
| 426 |
* @progress: a valid #PkProgress instance |
| 427 |
* @role: a #PkRoleEnum |
| 428 |
* |
| 429 |
* Set the role of this transaction. |
| 430 |
* |
| 431 |
* Return value: %TRUE if value changed. |
| 432 |
* |
| 433 |
* Since: 0.5.2 |
| 434 |
**/ |
| 435 |
gboolean |
| 436 |
pk_progress_set_role (PkProgress *progress, PkRoleEnum role) |
| 437 |
{ |
| 438 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 439 |
|
| 440 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 441 |
|
| 442 |
/* ignore unknown as we don't want to replace a valid value */ |
| 443 |
if (role == PK_ROLE_ENUM_UNKNOWN) |
| 444 |
return FALSE; |
| 445 |
|
| 446 |
/* the same as before? */ |
| 447 |
if (priv->role == role) |
| 448 |
return FALSE; |
| 449 |
|
| 450 |
/* new value */ |
| 451 |
priv->role = role; |
| 452 |
g_debug ("role now %s", pk_role_enum_to_string (role)); |
| 453 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_ROLE]); |
| 454 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_ROLE); |
| 455 |
|
| 456 |
return TRUE; |
| 457 |
} |
| 458 |
|
| 459 |
/** |
| 460 |
* pk_progress_get_role: |
| 461 |
* @progress: a valid #PkProgress instance |
| 462 |
* |
| 463 |
* Get the role of this transaction. |
| 464 |
* |
| 465 |
* Return value: a #PkRoleEnum |
| 466 |
* |
| 467 |
* Since: 1.0.12 |
| 468 |
**/ |
| 469 |
PkRoleEnum |
| 470 |
pk_progress_get_role (PkProgress *progress) |
| 471 |
{ |
| 472 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 473 |
|
| 474 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), PK_ROLE_ENUM_UNKNOWN); |
| 475 |
|
| 476 |
return priv->role; |
| 477 |
} |
| 478 |
|
| 479 |
/** |
| 480 |
* pk_progress_set_allow_cancel: |
| 481 |
* @progress: a valid #PkProgress instance |
| 482 |
* @allow_cancel: %TRUE if this transaction can be cancelled. |
| 483 |
* |
| 484 |
* Set if this transaction can be cancelled. |
| 485 |
* |
| 486 |
* Return value: %TRUE if value changed. |
| 487 |
* |
| 488 |
* Since: 0.5.2 |
| 489 |
**/ |
| 490 |
gboolean |
| 491 |
pk_progress_set_allow_cancel (PkProgress *progress, gboolean allow_cancel) |
| 492 |
{ |
| 493 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 494 |
|
| 495 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 496 |
|
| 497 |
/* the same as before? */ |
| 498 |
if (priv->allow_cancel == allow_cancel) |
| 499 |
return FALSE; |
| 500 |
|
| 501 |
/* new value */ |
| 502 |
priv->allow_cancel = allow_cancel; |
| 503 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_ALLOW_CANCEL]); |
| 504 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_ALLOW_CANCEL); |
| 505 |
|
| 506 |
return TRUE; |
| 507 |
} |
| 508 |
|
| 509 |
/** |
| 510 |
* pk_progress_get_allow_cancel: |
| 511 |
* @progress: a valid #PkProgress instance |
| 512 |
* |
| 513 |
* Get if this transaction can be cancelled. |
| 514 |
* |
| 515 |
* Return value: %TRUE if progress can be cancelled. |
| 516 |
* |
| 517 |
* Since: 1.0.12 |
| 518 |
**/ |
| 519 |
gboolean |
| 520 |
pk_progress_get_allow_cancel (PkProgress *progress) |
| 521 |
{ |
| 522 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 523 |
|
| 524 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 525 |
|
| 526 |
return priv->allow_cancel; |
| 527 |
} |
| 528 |
|
| 529 |
/** |
| 530 |
* pk_progress_set_caller_active: |
| 531 |
* @progress: a valid #PkProgress instance |
| 532 |
* @caller_active: %TRUE if the transaction caller is still connected. |
| 533 |
* |
| 534 |
* Set if the transaction caller is connected. |
| 535 |
* |
| 536 |
* Return value: %TRUE if value changed. |
| 537 |
* |
| 538 |
* Since: 0.5.2 |
| 539 |
**/ |
| 540 |
gboolean |
| 541 |
pk_progress_set_caller_active (PkProgress *progress, gboolean caller_active) |
| 542 |
{ |
| 543 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 544 |
|
| 545 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 546 |
|
| 547 |
/* the same as before? */ |
| 548 |
if (priv->caller_active == caller_active) |
| 549 |
return FALSE; |
| 550 |
|
| 551 |
/* new value */ |
| 552 |
priv->caller_active = caller_active; |
| 553 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_CALLER_ACTIVE]); |
| 554 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_CALLER_ACTIVE); |
| 555 |
|
| 556 |
return TRUE; |
| 557 |
} |
| 558 |
|
| 559 |
/** |
| 560 |
* pk_progress_get_caller_active: |
| 561 |
* @progress: a valid #PkProgress instance |
| 562 |
* |
| 563 |
* Get if the transaction caller is connected. |
| 564 |
* |
| 565 |
* Return value: %TRUE if the transaction caller is still connected. |
| 566 |
* |
| 567 |
* Since: 1.0.12 |
| 568 |
**/ |
| 569 |
gboolean |
| 570 |
pk_progress_get_caller_active (PkProgress *progress) |
| 571 |
{ |
| 572 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 573 |
|
| 574 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 575 |
|
| 576 |
return priv->caller_active; |
| 577 |
} |
| 578 |
|
| 579 |
/** |
| 580 |
* pk_progress_set_elapsed_time: |
| 581 |
* @progress: a valid #PkProgress instance |
| 582 |
* @elapsed_time: time in seconds |
| 583 |
* |
| 584 |
* Set the amount of time the transaction has taken. |
| 585 |
* |
| 586 |
* Return value: %TRUE if value changed. |
| 587 |
* |
| 588 |
* Since: 0.5.2 |
| 589 |
**/ |
| 590 |
gboolean |
| 591 |
pk_progress_set_elapsed_time (PkProgress *progress, guint elapsed_time) |
| 592 |
{ |
| 593 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 594 |
|
| 595 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 596 |
|
| 597 |
/* the same as before? */ |
| 598 |
if (priv->elapsed_time == elapsed_time) |
| 599 |
return FALSE; |
| 600 |
|
| 601 |
/* new value */ |
| 602 |
priv->elapsed_time = elapsed_time; |
| 603 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_ELAPSED_TIME]); |
| 604 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_ELAPSED_TIME); |
| 605 |
|
| 606 |
return TRUE; |
| 607 |
} |
| 608 |
|
| 609 |
/** |
| 610 |
* pk_progress_get_elapsed_time: |
| 611 |
* @progress: a valid #PkProgress instance |
| 612 |
* |
| 613 |
* Get the amount of time the transaction has taken. |
| 614 |
* |
| 615 |
* Return value: time in seconds |
| 616 |
* |
| 617 |
* Since: 1.0.12 |
| 618 |
**/ |
| 619 |
guint |
| 620 |
pk_progress_get_elapsed_time (PkProgress *progress) |
| 621 |
{ |
| 622 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 623 |
|
| 624 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), 0); |
| 625 |
|
| 626 |
return priv->elapsed_time; |
| 627 |
} |
| 628 |
|
| 629 |
/** |
| 630 |
* pk_progress_set_remaining_time: |
| 631 |
* @progress: a valid #PkProgress instance |
| 632 |
* @remaining_time: time in seconds or 0 if unknown. |
| 633 |
* |
| 634 |
* Set the amount of time the transaction will take to complete. |
| 635 |
* |
| 636 |
* Return value: %TRUE if value changed. |
| 637 |
* |
| 638 |
* Since: 0.5.2 |
| 639 |
**/ |
| 640 |
gboolean |
| 641 |
pk_progress_set_remaining_time (PkProgress *progress, guint remaining_time) |
| 642 |
{ |
| 643 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 644 |
|
| 645 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 646 |
|
| 647 |
/* the same as before? */ |
| 648 |
if (priv->remaining_time == remaining_time) |
| 649 |
return FALSE; |
| 650 |
|
| 651 |
/* new value */ |
| 652 |
priv->remaining_time = remaining_time; |
| 653 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_REMAINING_TIME]); |
| 654 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_REMAINING_TIME); |
| 655 |
|
| 656 |
return TRUE; |
| 657 |
} |
| 658 |
|
| 659 |
/** |
| 660 |
* pk_progress_get_remaining_time: |
| 661 |
* @progress: a valid #PkProgress instance |
| 662 |
* |
| 663 |
* Get the amount of time the transaction will take to complete. |
| 664 |
* |
| 665 |
* Return value: time in seconds or 0 if unknown. |
| 666 |
* |
| 667 |
* Since: 1.0.12 |
| 668 |
**/ |
| 669 |
guint |
| 670 |
pk_progress_get_remaining_time (PkProgress *progress) |
| 671 |
{ |
| 672 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 673 |
|
| 674 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), 0); |
| 675 |
|
| 676 |
return priv->remaining_time; |
| 677 |
} |
| 678 |
|
| 679 |
/** |
| 680 |
* pk_progress_set_speed: |
| 681 |
* @progress: a valid #PkProgress instance |
| 682 |
* @speed: speed in bits per second or 0 if unknown |
| 683 |
* |
| 684 |
* Set the speed of this transaction. |
| 685 |
* |
| 686 |
* Return value: %TRUE if value changed. |
| 687 |
* |
| 688 |
* Since: 0.5.2 |
| 689 |
**/ |
| 690 |
gboolean |
| 691 |
pk_progress_set_speed (PkProgress *progress, guint speed) |
| 692 |
{ |
| 693 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 694 |
|
| 695 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 696 |
|
| 697 |
/* the same as before? */ |
| 698 |
if (priv->speed == speed) |
| 699 |
return FALSE; |
| 700 |
|
| 701 |
/* new value */ |
| 702 |
priv->speed = speed; |
| 703 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_SPEED]); |
| 704 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_SPEED); |
| 705 |
|
| 706 |
return TRUE; |
| 707 |
} |
| 708 |
|
| 709 |
/** |
| 710 |
* pk_progress_get_speed: |
| 711 |
* @progress: a valid #PkProgress instance |
| 712 |
* |
| 713 |
* Get the speed of this transaction. |
| 714 |
* |
| 715 |
* Return value: speed in bits per scond or 0 if unknown |
| 716 |
* |
| 717 |
* Since: 1.0.12 |
| 718 |
**/ |
| 719 |
guint |
| 720 |
pk_progress_get_speed (PkProgress *progress) |
| 721 |
{ |
| 722 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 723 |
|
| 724 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), 0); |
| 725 |
|
| 726 |
return priv->speed; |
| 727 |
} |
| 728 |
|
| 729 |
/** |
| 730 |
* pk_progress_set_download_size_remaining: |
| 731 |
* @progress: a valid #PkProgress instance |
| 732 |
* @download_size_remaining: number of bytes remaining to download. |
| 733 |
* |
| 734 |
* Set the number of bytes remaining to download. |
| 735 |
* |
| 736 |
* Return value: %TRUE if value changed. |
| 737 |
* |
| 738 |
* Since: 0.8.0 |
| 739 |
**/ |
| 740 |
gboolean |
| 741 |
pk_progress_set_download_size_remaining (PkProgress *progress, guint64 download_size_remaining) |
| 742 |
{ |
| 743 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 744 |
|
| 745 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 746 |
|
| 747 |
/* the same as before? */ |
| 748 |
if (priv->download_size_remaining == download_size_remaining) |
| 749 |
return FALSE; |
| 750 |
|
| 751 |
/* new value */ |
| 752 |
priv->download_size_remaining = download_size_remaining; |
| 753 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_DOWNLOAD_SIZE_REMAINING]); |
| 754 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_DOWNLOAD_SIZE_REMAINING); |
| 755 |
|
| 756 |
return TRUE; |
| 757 |
} |
| 758 |
|
| 759 |
/** |
| 760 |
* pk_progress_get_download_size_remaining: |
| 761 |
* @progress: a valid #PkProgress instance |
| 762 |
* |
| 763 |
* Get the number of bytes remaining to download. |
| 764 |
* |
| 765 |
* Return value: number of bytes remaining to download. |
| 766 |
* |
| 767 |
* Since: 1.0.12 |
| 768 |
**/ |
| 769 |
guint64 |
| 770 |
pk_progress_get_download_size_remaining (PkProgress *progress) |
| 771 |
{ |
| 772 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 773 |
|
| 774 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), 0); |
| 775 |
|
| 776 |
return priv->download_size_remaining; |
| 777 |
} |
| 778 |
|
| 779 |
/** |
| 780 |
* pk_progress_set_transaction_flags: |
| 781 |
* @progress: a valid #PkProgress instance |
| 782 |
* @transaction_flags: a #PkBitfield containing #PkTransactionFlagEnum values. |
| 783 |
* |
| 784 |
* Set the flags associated with this transaction. |
| 785 |
* |
| 786 |
* Return value: %TRUE if value changed. |
| 787 |
* |
| 788 |
* Since: 0.8.8 |
| 789 |
**/ |
| 790 |
gboolean |
| 791 |
pk_progress_set_transaction_flags (PkProgress *progress, guint64 transaction_flags) |
| 792 |
{ |
| 793 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 794 |
|
| 795 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 796 |
|
| 797 |
/* the same as before? */ |
| 798 |
if (priv->transaction_flags == transaction_flags) |
| 799 |
return FALSE; |
| 800 |
|
| 801 |
/* new value */ |
| 802 |
priv->transaction_flags = transaction_flags; |
| 803 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_TRANSACTION_FLAGS]); |
| 804 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_TRANSACTION_FLAGS); |
| 805 |
|
| 806 |
return TRUE; |
| 807 |
} |
| 808 |
|
| 809 |
/** |
| 810 |
* pk_progress_get_transaction_flags: |
| 811 |
* @progress: a valid #PkProgress instance |
| 812 |
* |
| 813 |
* Get the flags associated with this transaction. |
| 814 |
* |
| 815 |
* Return value: a #PkBitfield containing #PkTransactionFlagEnum values. |
| 816 |
* |
| 817 |
* Since: 1.0.12 |
| 818 |
**/ |
| 819 |
guint64 |
| 820 |
pk_progress_get_transaction_flags (PkProgress *progress) |
| 821 |
{ |
| 822 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 823 |
|
| 824 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), 0); |
| 825 |
|
| 826 |
return priv->transaction_flags; |
| 827 |
} |
| 828 |
|
| 829 |
/** |
| 830 |
* pk_progress_set_uid: |
| 831 |
* @progress: a valid #PkProgress instance |
| 832 |
* @uid: a UID |
| 833 |
* |
| 834 |
* Set the UID that started this transaction. |
| 835 |
* |
| 836 |
* Return value: %TRUE if value changed. |
| 837 |
* |
| 838 |
* Since: 0.5.2 |
| 839 |
**/ |
| 840 |
gboolean |
| 841 |
pk_progress_set_uid (PkProgress *progress, guint uid) |
| 842 |
{ |
| 843 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 844 |
|
| 845 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 846 |
|
| 847 |
/* the same as before? */ |
| 848 |
if (priv->uid == uid) |
| 849 |
return FALSE; |
| 850 |
|
| 851 |
/* new value */ |
| 852 |
priv->uid = uid; |
| 853 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_UID]); |
| 854 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_UID); |
| 855 |
|
| 856 |
return TRUE; |
| 857 |
} |
| 858 |
|
| 859 |
/** |
| 860 |
* pk_progress_get_uid: |
| 861 |
* @progress: a valid #PkProgress instance |
| 862 |
* |
| 863 |
* Get the UID that started this transaction. |
| 864 |
* |
| 865 |
* Return value: an UID |
| 866 |
* |
| 867 |
* Since: 1.0.12 |
| 868 |
**/ |
| 869 |
guint |
| 870 |
pk_progress_get_uid (PkProgress *progress) |
| 871 |
{ |
| 872 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 873 |
|
| 874 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), 0); |
| 875 |
|
| 876 |
return priv->uid; |
| 877 |
} |
| 878 |
|
| 879 |
/** |
| 880 |
* pk_progress_set_sender: |
| 881 |
* @progress: a valid #PkProgress instance |
| 882 |
* @bus_name: a D-Bus name |
| 883 |
* |
| 884 |
* Set the D-Bus name of the client that started this transaction. |
| 885 |
* |
| 886 |
* Return value: %TRUE if value changed. |
| 887 |
* |
| 888 |
* Since: 1.2.6 |
| 889 |
**/ |
| 890 |
gboolean |
| 891 |
pk_progress_set_sender (PkProgress *progress, const gchar *bus_name) |
| 892 |
{ |
| 893 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 894 |
|
| 895 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 896 |
|
| 897 |
/* the same as before? */ |
| 898 |
if (g_strcmp0 (priv->sender, bus_name) == 0) |
| 899 |
return FALSE; |
| 900 |
|
| 901 |
/* new value */ |
| 902 |
g_free (priv->sender); |
| 903 |
priv->sender = g_strdup (bus_name); |
| 904 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_SENDER]); |
| 905 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_SENDER); |
| 906 |
|
| 907 |
return TRUE; |
| 908 |
} |
| 909 |
|
| 910 |
/** |
| 911 |
* pk_progress_get_sender: |
| 912 |
* @progress: a valid #PkProgress instance |
| 913 |
* |
| 914 |
* Get the D-Bus name of the client that started this transaction. |
| 915 |
* |
| 916 |
* Return value: a D-Bus name |
| 917 |
* |
| 918 |
* Since: 1.2.6 |
| 919 |
**/ |
| 920 |
gchar* |
| 921 |
pk_progress_get_sender (PkProgress *progress) |
| 922 |
{ |
| 923 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 924 |
|
| 925 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), NULL); |
| 926 |
|
| 927 |
return priv->sender; |
| 928 |
} |
| 929 |
|
| 930 |
/** |
| 931 |
* pk_progress_set_package: |
| 932 |
* @progress: a valid #PkProgress instance |
| 933 |
* @package: a #PkPackage |
| 934 |
* |
| 935 |
* Set the package this transaction is acting on. |
| 936 |
* |
| 937 |
* Return value: %TRUE if value changed. |
| 938 |
* |
| 939 |
* Since: 0.5.2 |
| 940 |
**/ |
| 941 |
gboolean |
| 942 |
pk_progress_set_package (PkProgress *progress, PkPackage *package) |
| 943 |
{ |
| 944 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 945 |
|
| 946 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE); |
| 947 |
|
| 948 |
if (g_set_object (&priv->package, package)) { |
| 949 |
g_object_notify_by_pspec (G_OBJECT(progress), obj_properties[PROP_PACKAGE]); |
| 950 |
pk_progress_invoke_callback (progress, PK_PROGRESS_TYPE_PACKAGE); |
| 951 |
return TRUE; |
| 952 |
} |
| 953 |
|
| 954 |
return FALSE; |
| 955 |
} |
| 956 |
|
| 957 |
/** |
| 958 |
* pk_progress_get_package: |
| 959 |
* @progress: a valid #PkProgress instance |
| 960 |
* |
| 961 |
* Get the package this transaction is acting on. |
| 962 |
* |
| 963 |
* Return value: (transfer none): a #PkPackage |
| 964 |
* |
| 965 |
* Since: 1.0.12 |
| 966 |
**/ |
| 967 |
PkPackage * |
| 968 |
pk_progress_get_package (PkProgress *progress) |
| 969 |
{ |
| 970 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 971 |
|
| 972 |
g_return_val_if_fail (PK_IS_PROGRESS (progress), NULL); |
| 973 |
|
| 974 |
return priv->package; |
| 975 |
} |
| 976 |
|
| 977 |
/** |
| 978 |
* pk_progress_new_with_callback: |
| 979 |
* @callback: (scope notified): the function to run when the progress changes |
| 980 |
* @user_data: data to pass to @callback |
| 981 |
* |
| 982 |
* Create a progress with a callback function. |
| 983 |
* |
| 984 |
* Returns: (transfer full): a new #PkProgress |
| 985 |
**/ |
| 986 |
PkProgress * |
| 987 |
pk_progress_new_with_callback (PkProgressCallback callback, gpointer user_data) |
| 988 |
{ |
| 989 |
PkProgress *progress; |
| 990 |
PkProgressPrivate *priv; |
| 991 |
|
| 992 |
progress = pk_progress_new (); |
| 993 |
priv = pk_progress_get_instance_private (progress); |
| 994 |
priv->callback = callback; |
| 995 |
priv->callback_user_data = user_data; |
| 996 |
|
| 997 |
return progress; |
| 998 |
} |
| 999 |
|
| 1000 |
/* |
| 1001 |
* pk_progress_set_property: |
| 1002 |
**/ |
| 1003 |
static void |
| 1004 |
pk_progress_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) |
| 1005 |
{ |
| 1006 |
PkProgress *progress = PK_PROGRESS (object); |
| 1007 |
|
| 1008 |
switch (prop_id) { |
| 1009 |
case PROP_PACKAGE_ID: |
| 1010 |
pk_progress_set_package_id (progress, g_value_get_string (value)); |
| 1011 |
break; |
| 1012 |
case PROP_TRANSACTION_ID: |
| 1013 |
pk_progress_set_transaction_id (progress, g_value_get_string (value)); |
| 1014 |
break; |
| 1015 |
case PROP_PERCENTAGE: |
| 1016 |
pk_progress_set_percentage (progress, g_value_get_int (value)); |
| 1017 |
break; |
| 1018 |
case PROP_ALLOW_CANCEL: |
| 1019 |
pk_progress_set_allow_cancel (progress, g_value_get_boolean (value)); |
| 1020 |
break; |
| 1021 |
case PROP_STATUS: |
| 1022 |
pk_progress_set_status (progress, g_value_get_uint (value)); |
| 1023 |
break; |
| 1024 |
case PROP_ROLE: |
| 1025 |
pk_progress_set_role (progress, g_value_get_uint (value)); |
| 1026 |
break; |
| 1027 |
case PROP_CALLER_ACTIVE: |
| 1028 |
pk_progress_set_caller_active (progress, g_value_get_boolean (value)); |
| 1029 |
break; |
| 1030 |
case PROP_ELAPSED_TIME: |
| 1031 |
pk_progress_set_elapsed_time (progress, g_value_get_uint (value)); |
| 1032 |
break; |
| 1033 |
case PROP_REMAINING_TIME: |
| 1034 |
pk_progress_set_remaining_time (progress, g_value_get_uint (value)); |
| 1035 |
break; |
| 1036 |
case PROP_SPEED: |
| 1037 |
pk_progress_set_speed (progress, g_value_get_uint (value)); |
| 1038 |
break; |
| 1039 |
case PROP_UID: |
| 1040 |
pk_progress_set_uid (progress, g_value_get_uint (value)); |
| 1041 |
break; |
| 1042 |
case PROP_PACKAGE: |
| 1043 |
pk_progress_set_package (progress, g_value_get_object (value)); |
| 1044 |
break; |
| 1045 |
case PROP_ITEM_PROGRESS: |
| 1046 |
pk_progress_set_item_progress (progress, g_value_get_object (value)); |
| 1047 |
break; |
| 1048 |
case PROP_SENDER: |
| 1049 |
pk_progress_set_sender (progress, g_value_get_string (value)); |
| 1050 |
break; |
| 1051 |
case PROP_DOWNLOAD_SIZE_REMAINING: |
| 1052 |
pk_progress_set_download_size_remaining (progress, g_value_get_uint64 (value)); |
| 1053 |
break; |
| 1054 |
case PROP_TRANSACTION_FLAGS: |
| 1055 |
pk_progress_set_transaction_flags (progress, g_value_get_uint64 (value)); |
| 1056 |
break; |
| 1057 |
default: |
| 1058 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
| 1059 |
break; |
| 1060 |
} |
| 1061 |
} |
| 1062 |
|
| 1063 |
/* |
| 1064 |
* pk_progress_class_init: |
| 1065 |
**/ |
| 1066 |
static void |
| 1067 |
pk_progress_class_init (PkProgressClass *klass) |
| 1068 |
{ |
| 1069 |
GObjectClass *object_class = G_OBJECT_CLASS (klass); |
| 1070 |
object_class->get_property = pk_progress_get_property; |
| 1071 |
object_class->set_property = pk_progress_set_property; |
| 1072 |
object_class->dispose = pk_progress_dispose; |
| 1073 |
object_class->finalize = pk_progress_finalize; |
| 1074 |
|
| 1075 |
/** |
| 1076 |
* PkProgress:package-id: |
| 1077 |
* |
| 1078 |
* Full package ID this transaction is acting on. |
| 1079 |
* e.g. 'gnome-power-manager;0.1.2;i386;fedora' |
| 1080 |
* |
| 1081 |
* Since: 0.5.2 |
| 1082 |
*/ |
| 1083 |
obj_properties[PROP_PACKAGE_ID] = |
| 1084 |
g_param_spec_string ("package-id", NULL, NULL, |
| 1085 |
NULL, |
| 1086 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1087 |
|
| 1088 |
/** |
| 1089 |
* PkProgress:transaction-id: |
| 1090 |
* |
| 1091 |
* ID used by this transaction. |
| 1092 |
* |
| 1093 |
* Since: 0.5.2 |
| 1094 |
*/ |
| 1095 |
obj_properties[PROP_TRANSACTION_ID] = |
| 1096 |
g_param_spec_string ("transaction-id", NULL, NULL, |
| 1097 |
NULL, |
| 1098 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1099 |
|
| 1100 |
/** |
| 1101 |
* PkProgress:percentage: |
| 1102 |
* |
| 1103 |
* Percentage complete of this transaction. |
| 1104 |
* |
| 1105 |
* Since: 0.5.2 |
| 1106 |
*/ |
| 1107 |
obj_properties[PROP_PERCENTAGE] = |
| 1108 |
g_param_spec_int ("percentage", NULL, NULL, |
| 1109 |
-1, G_MAXINT, -1, |
| 1110 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1111 |
|
| 1112 |
/** |
| 1113 |
* PkProgress:allow-cancel: |
| 1114 |
* |
| 1115 |
* %TRUE if this transaction can be cancelled. |
| 1116 |
* |
| 1117 |
* Since: 0.5.2 |
| 1118 |
*/ |
| 1119 |
obj_properties[PROP_ALLOW_CANCEL] = |
| 1120 |
g_param_spec_boolean ("allow-cancel", NULL, NULL, |
| 1121 |
FALSE, |
| 1122 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1123 |
|
| 1124 |
/** |
| 1125 |
* PkProgress:status: |
| 1126 |
* |
| 1127 |
* Status of this transaction. |
| 1128 |
* |
| 1129 |
* Since: 0.5.2 |
| 1130 |
*/ |
| 1131 |
obj_properties[PROP_STATUS] = |
| 1132 |
g_param_spec_uint ("status", NULL, NULL, |
| 1133 |
0, PK_STATUS_ENUM_LAST, PK_STATUS_ENUM_UNKNOWN, |
| 1134 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1135 |
|
| 1136 |
/** |
| 1137 |
* PkProgress:role: |
| 1138 |
* |
| 1139 |
* Role of this transaction. |
| 1140 |
* |
| 1141 |
* Since: 0.5.2 |
| 1142 |
*/ |
| 1143 |
obj_properties[PROP_ROLE] = |
| 1144 |
g_param_spec_uint ("role", NULL, NULL, |
| 1145 |
0, PK_ROLE_ENUM_LAST, PK_ROLE_ENUM_UNKNOWN, |
| 1146 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1147 |
|
| 1148 |
/** |
| 1149 |
* PkProgress:caller-active: |
| 1150 |
* |
| 1151 |
* %TRUE if the transaction caller is still connected. |
| 1152 |
* |
| 1153 |
* Since: 0.5.2 |
| 1154 |
*/ |
| 1155 |
obj_properties[PROP_CALLER_ACTIVE] = |
| 1156 |
g_param_spec_boolean ("caller-active", NULL, NULL, |
| 1157 |
FALSE, |
| 1158 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1159 |
|
| 1160 |
/** |
| 1161 |
* PkProgress:elapsed-time: |
| 1162 |
* |
| 1163 |
* Amount of time the transaction has taken in seconds. |
| 1164 |
* |
| 1165 |
* Since: 0.5.2 |
| 1166 |
*/ |
| 1167 |
obj_properties[PROP_ELAPSED_TIME] = |
| 1168 |
g_param_spec_uint ("elapsed-time", NULL, NULL, |
| 1169 |
0, G_MAXUINT, 0, |
| 1170 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1171 |
|
| 1172 |
/** |
| 1173 |
* PkProgress:remaining-time: |
| 1174 |
* |
| 1175 |
* Amount of time the transaction will take to complete in seconds or 0 if unknown. |
| 1176 |
* |
| 1177 |
* Since: 0.5.2 |
| 1178 |
*/ |
| 1179 |
obj_properties[PROP_REMAINING_TIME] = |
| 1180 |
g_param_spec_uint ("remaining-time", NULL, NULL, |
| 1181 |
0, G_MAXUINT, 0, |
| 1182 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1183 |
|
| 1184 |
/** |
| 1185 |
* PkProgress:speed: |
| 1186 |
* |
| 1187 |
* Transaction speed in bits per second or 0 if unknown. |
| 1188 |
* |
| 1189 |
* Since: 0.5.2 |
| 1190 |
*/ |
| 1191 |
obj_properties[PROP_SPEED] = |
| 1192 |
g_param_spec_uint ("speed", NULL, NULL, |
| 1193 |
0, G_MAXUINT, 0, |
| 1194 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1195 |
|
| 1196 |
/** |
| 1197 |
* PkProgress:download-size-remaining: |
| 1198 |
* |
| 1199 |
* Number of bytes remaining to download. |
| 1200 |
* |
| 1201 |
* Since: 0.8.0 |
| 1202 |
*/ |
| 1203 |
obj_properties[PROP_DOWNLOAD_SIZE_REMAINING] = |
| 1204 |
g_param_spec_uint64 ("download-size-remaining", NULL, NULL, |
| 1205 |
0, G_MAXUINT64, 0, |
| 1206 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1207 |
|
| 1208 |
/** |
| 1209 |
* PkProgress:transaction-flags: |
| 1210 |
* |
| 1211 |
* A #PkBitfield containing #PkTransactionFlagEnum associated with this transaction. |
| 1212 |
* |
| 1213 |
* Since: 0.8.8 |
| 1214 |
*/ |
| 1215 |
obj_properties[PROP_TRANSACTION_FLAGS] = |
| 1216 |
g_param_spec_uint64 ("transaction-flags", NULL, NULL, |
| 1217 |
0, G_MAXUINT64, 0, |
| 1218 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1219 |
|
| 1220 |
/** |
| 1221 |
* PkProgress:uid: |
| 1222 |
* |
| 1223 |
* The UID that started this transaction. |
| 1224 |
* |
| 1225 |
* Since: 0.5.2 |
| 1226 |
*/ |
| 1227 |
obj_properties[PROP_UID] = |
| 1228 |
g_param_spec_uint ("uid", NULL, NULL, |
| 1229 |
0, G_MAXUINT, 0, |
| 1230 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1231 |
|
| 1232 |
/** |
| 1233 |
* PkProgress:sender: |
| 1234 |
* |
| 1235 |
* The D-Bus name of the client that started this transaction. |
| 1236 |
* |
| 1237 |
* Since: 1.2.6 |
| 1238 |
*/ |
| 1239 |
obj_properties[PROP_SENDER] = |
| 1240 |
g_param_spec_string ("sender", NULL, NULL, |
| 1241 |
NULL, |
| 1242 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1243 |
|
| 1244 |
/** |
| 1245 |
* PkProgress:package: |
| 1246 |
* |
| 1247 |
* The package this transaction is acting on. |
| 1248 |
* |
| 1249 |
* Since: 0.5.3 |
| 1250 |
*/ |
| 1251 |
obj_properties[PROP_PACKAGE] = |
| 1252 |
g_param_spec_object ("package", NULL, NULL, |
| 1253 |
PK_TYPE_PACKAGE, |
| 1254 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1255 |
|
| 1256 |
/** |
| 1257 |
* PkProgress:item-progress: |
| 1258 |
* |
| 1259 |
* Item progress associated with this transaction. |
| 1260 |
* |
| 1261 |
* Since: 0.8.1 |
| 1262 |
*/ |
| 1263 |
obj_properties[PROP_ITEM_PROGRESS] = |
| 1264 |
g_param_spec_object ("item-progress", NULL, NULL, |
| 1265 |
PK_TYPE_ITEM_PROGRESS, |
| 1266 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |
| 1267 |
|
| 1268 |
g_object_class_install_properties (object_class, PROP_LAST, obj_properties); |
| 1269 |
} |
| 1270 |
|
| 1271 |
/* |
| 1272 |
* pk_progress_init: |
| 1273 |
**/ |
| 1274 |
static void |
| 1275 |
pk_progress_init (PkProgress *progress) |
| 1276 |
{ |
| 1277 |
progress->priv = GET_PRIVATE(progress); |
| 1278 |
} |
| 1279 |
|
| 1280 |
/* |
| 1281 |
* pk_progress_dispose: |
| 1282 |
**/ |
| 1283 |
static void |
| 1284 |
pk_progress_dispose (GObject *object) |
| 1285 |
{ |
| 1286 |
PkProgress *progress = PK_PROGRESS (object); |
| 1287 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 1288 |
|
| 1289 |
g_clear_object (&priv->package); |
| 1290 |
g_clear_object (&priv->item_progress); |
| 1291 |
|
| 1292 |
G_OBJECT_CLASS (pk_progress_parent_class)->dispose (object); |
| 1293 |
} |
| 1294 |
|
| 1295 |
/* |
| 1296 |
* pk_progress_finalize: |
| 1297 |
**/ |
| 1298 |
static void |
| 1299 |
pk_progress_finalize (GObject *object) |
| 1300 |
{ |
| 1301 |
PkProgress *progress = PK_PROGRESS (object); |
| 1302 |
PkProgressPrivate *priv = GET_PRIVATE(progress); |
| 1303 |
|
| 1304 |
g_clear_pointer (&priv->package_id, g_free); |
| 1305 |
g_clear_pointer (&priv->transaction_id, g_free); |
| 1306 |
g_clear_pointer (&priv->sender, g_free); |
| 1307 |
|
| 1308 |
G_OBJECT_CLASS (pk_progress_parent_class)->finalize (object); |
| 1309 |
} |
| 1310 |
|
| 1311 |
/** |
| 1312 |
* pk_progress_new: |
| 1313 |
* |
| 1314 |
* #PkProgress is a nice GObject wrapper for PackageKit and makes writing |
| 1315 |
* frontends easy. |
| 1316 |
* |
| 1317 |
* Return value: A new #PkProgress instance |
| 1318 |
* |
| 1319 |
* Since: 0.5.2 |
| 1320 |
**/ |
| 1321 |
PkProgress * |
| 1322 |
pk_progress_new (void) |
| 1323 |
{ |
| 1324 |
PkProgress *progress; |
| 1325 |
progress = g_object_new (PK_TYPE_PROGRESS, NULL); |
| 1326 |
return PK_PROGRESS (progress); |
| 1327 |
} |