├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── app ├── CMakeLists.txt ├── main.cpp ├── papyros-appcenter.qrc └── qml │ ├── ApplicationPage.qml │ ├── IconItem.qml │ └── main.qml ├── cmake ├── FindGIO.cmake ├── FindGObject.cmake ├── FindGlib.cmake ├── FindXdgApp.cmake └── LibFindMacros.cmake ├── data ├── io.papyros.AppCenter.appdata.xml ├── io.papyros.AppCenter.desktop └── io.papyros.AppCenter.notifyrc ├── declarative ├── CMakeLists.txt ├── plugin.cpp ├── plugin.h └── qmldir ├── framework ├── CMakeLists.txt ├── SoftwareConfig.cmake.in ├── application.cpp ├── application.h ├── appstream │ ├── component.cpp │ ├── component.h │ ├── screenshot.cpp │ ├── screenshot.h │ ├── store.cpp │ ├── store.h │ ├── url.cpp │ └── url.h ├── autocast.h ├── backend.h ├── screenshot.cpp ├── screenshot.h ├── softwaremanager.cpp ├── softwaremanager.h ├── source.h ├── utils.cpp ├── utils.h └── xdg-app │ ├── base.h │ ├── xdg-application.cpp │ ├── xdg-application.h │ ├── xdg-backend.cpp │ ├── xdg-backend.h │ └── xdg-remote.h └── notifier ├── CMakeLists.txt ├── main.cpp └── updatenotifier.h /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | 3 | *.slo 4 | *.lo 5 | *.o 6 | *.a 7 | *.la 8 | *.lai 9 | *.so 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | 15 | /.qmake.cache 16 | /.qmake.stash 17 | *.pro.user 18 | *.pro.user.* 19 | *.qbs.user 20 | *.qbs.user.* 21 | *.moc 22 | moc_*.cpp 23 | qrc_*.cpp 24 | ui_*.h 25 | Makefile* 26 | *-build-* 27 | 28 | # QtCreator 29 | 30 | *.autosave 31 | 32 | #QtCtreator Qml 33 | *.qmlproject.user 34 | *.qmlproject.user.* 35 | 36 | build/ 37 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(io.papyros.AppCenter) 2 | 3 | cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) 4 | 5 | # Silence CMake warnings 6 | if(POLICY CMP0063) 7 | cmake_policy(SET CMP0063 NEW) 8 | endif() 9 | 10 | # Set version 11 | set(PROJECT_VERSION "0.1.0") 12 | set(PROJECT_VERSION_MAJOR 0) 13 | set(PROJECT_VERSION_MINOR 1) 14 | set(PROJECT_VERSION_PATCH 0) 15 | set(PROJECT_SOVERSION 0) 16 | 17 | # Find includes in corresponding build directories 18 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 19 | 20 | # Instruct CMake to run moc and rrc automatically when needed 21 | set(CMAKE_AUTOMOC ON) 22 | set(CMAKE_AUTORCC ON) 23 | 24 | # Extra CMake files 25 | find_package(ECM 0.0.11 REQUIRED NO_MODULE) 26 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) 27 | 28 | include(KDEInstallDirs) 29 | include(KDECMakeSettings) 30 | include(KDECompilerSettings) 31 | include(FeatureSummary) 32 | 33 | # Build flags 34 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -fvisibility=hidden -fvisibility-inlines-hidden -Werror -Wall -Wextra -Wno-unused-parameter -pedantic -std=c++11") 35 | 36 | # Disable debug output for release builds 37 | if(CMAKE_BUILD_TYPE MATCHES "^[Rr]elease$") 38 | add_definitions(-DQT_NO_DEBUG_OUTPUT) 39 | endif() 40 | 41 | # Minimum version requirements 42 | set(QT_MIN_VERSION "5.4.0") 43 | set(KF5_MIN_VERSION "5.8.0") 44 | 45 | # Find Qt5 46 | find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS 47 | Core 48 | Gui 49 | Qml 50 | Quick 51 | Xml 52 | Concurrent) 53 | 54 | find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS 55 | Archive Notifications) 56 | 57 | find_package(XdgApp REQUIRED) 58 | find_package(Papyros REQUIRED) 59 | 60 | # Install the desktop and appdata files 61 | install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/${PROJECT_NAME}.desktop 62 | DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) 63 | install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/${PROJECT_NAME}.notifyrc 64 | DESTINATION ${CMAKE_INSTALL_DATADIR}/knotifications5) 65 | install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/${PROJECT_NAME}.appdata.xml 66 | DESTINATION ${CMAKE_INSTALL_METAINFODIR}) 67 | 68 | add_subdirectory(app) 69 | add_subdirectory(declarative) 70 | add_subdirectory(framework) 71 | add_subdirectory(notifier) 72 | 73 | # Display feature summary 74 | feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) 75 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | 676 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # software-app 2 | The software center/app store for Papyros 3 | -------------------------------------------------------------------------------- /app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE SOURCES *.cpp *.h papyros-appcenter.qrc) 2 | 3 | add_executable(papyros-appcenter ${SOURCES}) 4 | target_link_libraries(papyros-appcenter 5 | Qt5::Quick 6 | KF5::Archive 7 | Papyros::Core) 8 | 9 | install(TARGETS papyros-appcenter 10 | DESTINATION ${CMAKE_INSTALL_BINDIR}) 11 | -------------------------------------------------------------------------------- /app/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define TR(x) QT_TRANSLATE_NOOP("Command line parser", QStringLiteral(x)) 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | QGuiApplication app(argc, argv); 14 | app.setApplicationName("App Center"); 15 | app.setOrganizationDomain("papyros.io"); 16 | app.setOrganizationName("Papyros"); 17 | 18 | #if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) 19 | app.setDesktopFileName("io.papyros.AppCenter.desktop"); 20 | #endif 21 | 22 | // Set the X11 WML_CLASS so X11 desktops can find the desktop file 23 | qputenv("RESOURCE_NAME", "io.papyros.AppCenter"); 24 | 25 | // TODO: Figure out why this is necessary 26 | QIcon::setThemeName("Paper"); 27 | 28 | QQmlApplicationEngine engine(QUrl(QStringLiteral("qrc:/qml/main.qml"))); 29 | 30 | return app.exec(); 31 | } 32 | -------------------------------------------------------------------------------- /app/papyros-appcenter.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | qml/main.qml 4 | qml/IconItem.qml 5 | qml/ApplicationPage.qml 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/qml/ApplicationPage.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.4 2 | import QtQuick.Controls 1.3 3 | import QtQuick.Layouts 1.0 4 | import Material 0.2 5 | import Material.ListItems 0.1 as ListItem 6 | import Papyros.Software 0.1 as Software 7 | 8 | Page { 9 | property var app 10 | property int selectedImageIndex 11 | 12 | title: app.name 13 | 14 | Flickable { 15 | id: scrollView 16 | anchors.fill: parent 17 | 18 | contentHeight: column.height + column.anchors.margins * 2 19 | 20 | ColumnLayout { 21 | id: column 22 | width: Math.min(Units.dp(800), scrollView.width - 2 * anchors.margins) 23 | 24 | spacing: Units.dp(16) 25 | 26 | anchors { 27 | horizontalCenter: parent.horizontalCenter 28 | top: parent.top 29 | margins: Units.dp(16) 30 | } 31 | 32 | RowLayout { 33 | Layout.fillWidth: true 34 | 35 | spacing: Units.dp(16) 36 | 37 | IconItem { 38 | id: image 39 | Layout.fillHeight: true 40 | Layout.preferredWidth: height 41 | 42 | icon: app.icon 43 | } 44 | 45 | ColumnLayout { 46 | Layout.alignment: Qt.AlignVCenter 47 | 48 | Label { 49 | text: app.name 50 | style: "headline" 51 | } 52 | 53 | Label { 54 | text: app.summary 55 | style: "subheading" 56 | color: Theme.light.subTextColor 57 | } 58 | } 59 | 60 | Item { 61 | Layout.fillWidth: true 62 | } 63 | 64 | Button { 65 | Layout.alignment: Qt.AlignVCenter 66 | 67 | text: app.state == Software.Application.Installed ? "Uninstall" : "Install" 68 | elevation: 1 69 | backgroundColor: app.state == Software.Application.Installed 70 | ? Palette.colors.red['500'] : Theme.primaryColor 71 | } 72 | 73 | Button { 74 | Layout.alignment: Qt.AlignVCenter 75 | 76 | visible: app.state == Software.Application.Installed 77 | text: "Open" 78 | elevation: 1 79 | // backgroundColor: Palette.colors.green['500'] 80 | onClicked: { 81 | if (!app.launch()) 82 | console.log("Something went wrong!") 83 | } 84 | } 85 | } 86 | 87 | RowLayout { 88 | Layout.fillWidth: true 89 | 90 | spacing: Units.dp(16) 91 | 92 | Image { 93 | Layout.fillWidth: true 94 | Layout.preferredHeight: width * sourceSize.height/sourceSize.width 95 | Layout.alignment: Qt.AlignTop 96 | 97 | source: app.screenshots.get(selectedImageIndex).url 98 | } 99 | 100 | ColumnLayout { 101 | Layout.alignment: Qt.AlignTop 102 | spacing: Units.dp(8) 103 | 104 | Repeater { 105 | model: app.screenshots 106 | delegate: Image { 107 | source: edit.url 108 | 109 | Layout.preferredWidth: Units.dp(120) 110 | Layout.preferredHeight: width * sourceSize.height/sourceSize.width 111 | 112 | Ink { 113 | anchors.fill: parent 114 | onClicked: selectedImageIndex = index 115 | } 116 | } 117 | } 118 | } 119 | } 120 | } 121 | } 122 | 123 | Scrollbar { 124 | flickableItem: scrollView 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /app/qml/IconItem.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.4 2 | import QtQuick.Window 2.2 3 | import org.kde.kquickcontrolsaddons 2.0 4 | 5 | Item { 6 | property alias icon: __icon.icon 7 | 8 | QIconItem { 9 | id: __icon 10 | 11 | property real ratio: Screen.devicePixelRatio 12 | 13 | scale: 1/ratio 14 | width: parent.width * ratio 15 | height: parent.height * ratio 16 | 17 | anchors.centerIn: parent 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/qml/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.4 2 | import QtQuick.Controls 1.2 3 | import Material 0.2 4 | import Material.ListItems 0.1 as ListItem 5 | import Papyros.Software 0.1 6 | import Papyros.Core 0.2 7 | import QtQuick.Window 2.2 8 | 9 | ApplicationWindow { 10 | id: demo 11 | 12 | title: "App Center" 13 | 14 | // Necessary when loading the window from C++ 15 | visible: true 16 | 17 | theme { 18 | primaryColor: "blue" 19 | accentColor: "blue" 20 | tabHighlightColor: "white" 21 | } 22 | 23 | Component.onCompleted: { 24 | if (session.shownWelcome == "false") 25 | welcomeDialog.open() 26 | } 27 | 28 | Action { 29 | id: searchAction 30 | 31 | iconName: "action/search" 32 | text: "Search" 33 | } 34 | 35 | initialPage: NavigationDrawerPage { 36 | id: navPage 37 | page: overviewPage 38 | 39 | navDrawer: NavigationDrawer { 40 | 41 | Column { 42 | anchors.fill: parent 43 | 44 | ListItem.Standard { 45 | text: "Applications" 46 | iconName: "action/shop" 47 | selected: navPage.page == overviewPage 48 | onClicked: navPage.navigate(overviewPage) 49 | } 50 | 51 | ListItem.Standard { 52 | text: "Installed Apps" 53 | iconName: "file/file_download" 54 | selected: navPage.page == installedPage 55 | onClicked: navPage.navigate(installedPage) 56 | } 57 | 58 | ListItem.Standard { 59 | text: "Settings" 60 | iconName: "action/settings" 61 | selected: navPage.page == settingsPage 62 | onClicked: navPage.navigate(settingsPage) 63 | } 64 | } 65 | } 66 | } 67 | 68 | Page { 69 | id: overviewPage 70 | title: "App Center" 71 | 72 | actions: [searchAction] 73 | 74 | // Column { 75 | // anchors.centerIn: parent 76 | // spacing: Units.dp(16) 77 | // opacity: 0.5 78 | // 79 | // Icon { 80 | // name: "action/shop" 81 | // size: Units.dp(96) 82 | // anchors.horizontalCenter: parent.horizontalCenter 83 | // } 84 | // 85 | // Label { 86 | // text: "Installing new applications is not supported yet" 87 | // style: "title" 88 | // anchors.horizontalCenter: parent.horizontalCenter 89 | // } 90 | // } 91 | 92 | ListView { 93 | anchors.fill: parent 94 | 95 | model: software.availableApps 96 | delegate: ListItem.Subtitled { 97 | action: IconItem { 98 | width: Units.dp(48) 99 | height: width 100 | anchors.centerIn: parent 101 | icon: edit.icon 102 | } 103 | text: edit.name 104 | subText: edit.summary 105 | valueText: edit.branch 106 | onClicked: pageStack.push(Qt.resolvedUrl("ApplicationPage.qml"), {app: edit}) 107 | } 108 | } 109 | } 110 | 111 | Page { 112 | id: installedPage 113 | title: "Installed Apps" 114 | 115 | actions: [searchAction] 116 | 117 | ListView { 118 | anchors.fill: parent 119 | 120 | model: software.installedApps 121 | delegate: ListItem.Subtitled { 122 | action: IconItem { 123 | width: Units.dp(48) 124 | height: width 125 | anchors.centerIn: parent 126 | icon: edit.icon 127 | } 128 | text: edit.name 129 | subText: edit.summary 130 | valueText: edit.branch 131 | onClicked: pageStack.push(Qt.resolvedUrl("ApplicationPage.qml"), {app: edit}) 132 | } 133 | } 134 | } 135 | 136 | Page { 137 | id: settingsPage 138 | title: "Settings" 139 | actionBar.backgroundColor: Palette.colors.blueGrey['700'] 140 | actionBar.decorationColor: Palette.colors.blueGrey['900'] 141 | 142 | ListView { 143 | anchors.fill: parent 144 | 145 | model: software.sources 146 | delegate: ListItem.Subtitled { 147 | text: edit.title ? "%1 (%2)".arg(edit.title).arg(edit.name) : edit.name 148 | subText: edit.url 149 | } 150 | } 151 | } 152 | 153 | Dialog { 154 | id: welcomeDialog 155 | 156 | Column { 157 | spacing: Units.dp(16) 158 | 159 | Item { 160 | width: parent.width 161 | height: Units.dp(16) 162 | } 163 | 164 | IconItem { 165 | anchors.horizontalCenter: parent.horizontalCenter 166 | icon: 'software-store' 167 | width: Units.dp(96) 168 | height: width 169 | } 170 | 171 | Label { 172 | style: "title" 173 | text: "Welcome to App Center" 174 | anchors.horizontalCenter: parent.horizontalCenter 175 | } 176 | 177 | Label { 178 | horizontalAlignment: Text.AlignJustify 179 | width: Units.dp(280) 180 | wrapMode: Text.Wrap 181 | style: "dialog" 182 | color: Theme.light.subTextColor 183 | text: "App Center lets you install all the software you need, all from one place. See our recommendations, browse the categories, or search for the applications you want." 184 | } 185 | } 186 | 187 | positiveButtonText: "Get Started" 188 | negativeButton.visible: false 189 | 190 | onAccepted: session.shownWelcome = "true" 191 | } 192 | 193 | SoftwareManager { 194 | id: software 195 | } 196 | 197 | KQuickConfig { 198 | id: session 199 | file: "papyros-appcenter" 200 | group: "session" 201 | 202 | defaults: { 203 | "shownWelcome": "false" 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /cmake/FindGIO.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find GIO 2.0 2 | # Once done, this will define 3 | # 4 | # GIO_FOUND - system has GIO 5 | # GIO_INCLUDE_DIRS - the GIO include directories 6 | # GIO_LIBRARIES - link these to use GIO 7 | 8 | include(LibFindMacros) 9 | 10 | # Dependencies 11 | libfind_package(GIO Glib) 12 | 13 | # Use pkg-config to get hints about paths 14 | libfind_pkg_check_modules(GIO_PKGCONF gio-2.0) 15 | 16 | # Find the library 17 | find_library(GIO_LIBRARY 18 | NAMES gio-2.0 19 | PATHS ${GIO_PKGCONF_LIBRARY_DIRS} 20 | ) 21 | 22 | # Set the include dir variables and the libraries and let libfind_process do the rest. 23 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 24 | set(GIO_PROCESS_INCLUDES Glib_INCLUDE_DIRS) 25 | set(GIO_PROCESS_LIBS GIO_LIBRARY Glib_LIBRARIES) 26 | libfind_process(GIO) 27 | -------------------------------------------------------------------------------- /cmake/FindGObject.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find GObject 2.0 2 | # Once done, this will define 3 | # 4 | # GObject_FOUND - system has GObject 5 | # GObject_INCLUDE_DIRS - the GObject include directories 6 | # GObject_LIBRARIES - link these to use GObject 7 | 8 | include(LibFindMacros) 9 | 10 | # Dependencies 11 | libfind_package(GObject Glib) 12 | 13 | # Use pkg-config to get hints about paths 14 | libfind_pkg_check_modules(GObject_PKGCONF gobject-2.0) 15 | 16 | # Find the library 17 | find_library(GObject_LIBRARY 18 | NAMES gobject-2.0 19 | HINTS ${GObject_PKGCONF_LIBRARY_DIRS} 20 | ) 21 | 22 | find_path(GObject_INCLUDE_DIR 23 | NAMES gobject/gobject.h 24 | HINTS ${GObject_PKGCONF_INCLUDE_DIRS} 25 | HINTS ${Glib_INCLUDE_DIRS} 26 | ) 27 | 28 | set(GObject_PROCESS_INCLUDES GObject_INCLUDE_DIR Glib_INCLUDE_DIR) 29 | set(GObject_PROCESS_LIBS GObject_LIBRARY Glib_LIBRARY) 30 | libfind_process(GObject) 31 | -------------------------------------------------------------------------------- /cmake/FindGlib.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find Glib-2.0 (with gobject) 2 | # Once done, this will define 3 | # 4 | # Glib_FOUND - system has Glib 5 | # Glib_INCLUDE_DIRS - the Glib include directories 6 | # Glib_LIBRARIES - link these to use Glib 7 | 8 | include(LibFindMacros) 9 | 10 | # Use pkg-config to get hints about paths 11 | libfind_pkg_check_modules(Glib_PKGCONF glib-2.0>=2.16) 12 | 13 | # Main include dir 14 | find_path(Glib_INCLUDE_DIR 15 | NAMES glib.h 16 | PATHS ${Glib_PKGCONF_INCLUDE_DIRS} 17 | PATH_SUFFIXES glib-2.0 18 | ) 19 | 20 | # Glib-related libraries also use a separate config header, which is in lib dir 21 | find_path(GlibConfig_INCLUDE_DIR 22 | NAMES glibconfig.h 23 | PATHS ${Glib_PKGCONF_INCLUDE_DIRS} /usr 24 | PATH_SUFFIXES lib/glib-2.0/include 25 | ) 26 | 27 | # Finally the library itself 28 | find_library(Glib_LIBRARY 29 | NAMES glib-2.0 30 | PATHS ${Glib_PKGCONF_LIBRARY_DIRS} 31 | ) 32 | 33 | # Set the include dir variables and the libraries and let libfind_process do the rest. 34 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 35 | set(Glib_PROCESS_INCLUDES Glib_INCLUDE_DIR GlibConfig_INCLUDE_DIR) 36 | set(Glib_PROCESS_LIBS Glib_LIBRARY) 37 | libfind_process(Glib) 38 | -------------------------------------------------------------------------------- /cmake/FindXdgApp.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find xdg-app 2 | # Once done, this will define 3 | # 4 | # XdgApp_FOUND - system has XdgApp 5 | # XdgApp_INCLUDE_DIRS - the XdgApp include directories 6 | # XdgApp_LIBRARIES - link these to use XdgApp 7 | 8 | include(LibFindMacros) 9 | 10 | # Dependencies 11 | libfind_package(XdgApp Glib) 12 | libfind_package(XdgApp GObject) 13 | libfind_package(XdgApp GIO) 14 | 15 | # Use pkg-config to get hints about paths 16 | libfind_pkg_check_modules(XdgApp_PKGCONF xdg-app) 17 | 18 | # Include dir 19 | find_path(XdgApp_INCLUDE_DIR 20 | NAMES xdg-app.h 21 | PATHS ${XdgApp_PKGCONF_INCLUDE_DIRS} 22 | ) 23 | 24 | # Finally the library itself 25 | find_library(XdgApp_LIBRARY 26 | NAMES xdg-app 27 | PATHS ${XdgApp_PKGCONF_LIBRARY_DIRS} 28 | ) 29 | 30 | # Set the include dir variables and the libraries and let libfind_process do the rest. 31 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 32 | set(XdgApp_PROCESS_INCLUDES XdgApp_INCLUDE_DIR Glib_INCLUDE_DIR GObject_INCLUDE_DIR GIO_INCLUDE_DIR) 33 | set(XdgApp_PROCESS_LIBS XdgApp_LIBRARY Glib_LIBRARY GObject_LIBRARY GIO_LIBRARY) 34 | libfind_process(XdgApp) 35 | -------------------------------------------------------------------------------- /cmake/LibFindMacros.cmake: -------------------------------------------------------------------------------- 1 | # Version 2.2 2 | # Public Domain, originally written by Lasse Kärkkäinen 3 | # Maintained at https://github.com/Tronic/cmake-modules 4 | # Please send your improvements as pull requests on Github. 5 | 6 | # Find another package and make it a dependency of the current package. 7 | # This also automatically forwards the "REQUIRED" argument. 8 | # Usage: libfind_package( [extra args to find_package]) 9 | macro (libfind_package PREFIX PKG) 10 | set(${PREFIX}_args ${PKG} ${ARGN}) 11 | if (${PREFIX}_FIND_REQUIRED) 12 | set(${PREFIX}_args ${${PREFIX}_args} REQUIRED) 13 | endif() 14 | find_package(${${PREFIX}_args}) 15 | set(${PREFIX}_DEPENDENCIES ${${PREFIX}_DEPENDENCIES};${PKG}) 16 | unset(${PREFIX}_args) 17 | endmacro() 18 | 19 | # A simple wrapper to make pkg-config searches a bit easier. 20 | # Works the same as CMake's internal pkg_check_modules but is always quiet. 21 | macro (libfind_pkg_check_modules) 22 | find_package(PkgConfig QUIET) 23 | if (PKG_CONFIG_FOUND) 24 | pkg_check_modules(${ARGN} QUIET) 25 | endif() 26 | endmacro() 27 | 28 | # Avoid useless copy&pasta by doing what most simple libraries do anyway: 29 | # pkg-config, find headers, find library. 30 | # Usage: libfind_pkg_detect( FIND_PATH [other args] FIND_LIBRARY [other args]) 31 | # E.g. libfind_pkg_detect(SDL2 sdl2 FIND_PATH SDL.h PATH_SUFFIXES SDL2 FIND_LIBRARY SDL2) 32 | function (libfind_pkg_detect PREFIX) 33 | # Parse arguments 34 | set(argname pkgargs) 35 | foreach (i ${ARGN}) 36 | if ("${i}" STREQUAL "FIND_PATH") 37 | set(argname pathargs) 38 | elseif ("${i}" STREQUAL "FIND_LIBRARY") 39 | set(argname libraryargs) 40 | else() 41 | set(${argname} ${${argname}} ${i}) 42 | endif() 43 | endforeach() 44 | if (NOT pkgargs) 45 | message(FATAL_ERROR "libfind_pkg_detect requires at least a pkg_config package name to be passed.") 46 | endif() 47 | # Find library 48 | libfind_pkg_check_modules(${PREFIX}_PKGCONF ${pkgargs}) 49 | if (pathargs) 50 | find_path(${PREFIX}_INCLUDE_DIR NAMES ${pathargs} HINTS ${${PREFIX}_PKGCONF_INCLUDE_DIRS}) 51 | endif() 52 | if (libraryargs) 53 | find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}) 54 | endif() 55 | endfunction() 56 | 57 | # Extracts a version #define from a version.h file, output stored to _VERSION. 58 | # Usage: libfind_version_header(Foobar foobar/version.h FOOBAR_VERSION_STR) 59 | # Fourth argument "QUIET" may be used for silently testing different define names. 60 | # This function does nothing if the version variable is already defined. 61 | function (libfind_version_header PREFIX VERSION_H DEFINE_NAME) 62 | # Skip processing if we already have a version or if the include dir was not found 63 | if (${PREFIX}_VERSION OR NOT ${PREFIX}_INCLUDE_DIR) 64 | return() 65 | endif() 66 | set(quiet ${${PREFIX}_FIND_QUIETLY}) 67 | # Process optional arguments 68 | foreach(arg ${ARGN}) 69 | if (arg STREQUAL "QUIET") 70 | set(quiet TRUE) 71 | else() 72 | message(AUTHOR_WARNING "Unknown argument ${arg} to libfind_version_header ignored.") 73 | endif() 74 | endforeach() 75 | # Read the header and parse for version number 76 | set(filename "${${PREFIX}_INCLUDE_DIR}/${VERSION_H}") 77 | if (NOT EXISTS ${filename}) 78 | if (NOT quiet) 79 | message(AUTHOR_WARNING "Unable to find ${${PREFIX}_INCLUDE_DIR}/${VERSION_H}") 80 | endif() 81 | return() 82 | endif() 83 | file(READ "${filename}" header) 84 | string(REGEX REPLACE ".*#[ \t]*define[ \t]*${DEFINE_NAME}[ \t]*\"([^\n]*)\".*" "\\1" match "${header}") 85 | # No regex match? 86 | if (match STREQUAL header) 87 | if (NOT quiet) 88 | message(AUTHOR_WARNING "Unable to find \#define ${DEFINE_NAME} \"\" from ${${PREFIX}_INCLUDE_DIR}/${VERSION_H}") 89 | endif() 90 | return() 91 | endif() 92 | # Export the version string 93 | set(${PREFIX}_VERSION "${match}" PARENT_SCOPE) 94 | endfunction() 95 | 96 | # Do the final processing once the paths have been detected. 97 | # If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain 98 | # all the variables, each of which contain one include directory. 99 | # Ditto for ${PREFIX}_PROCESS_LIBS and library files. 100 | # Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES. 101 | # Also handles errors in case library detection was required, etc. 102 | function (libfind_process PREFIX) 103 | # Skip processing if already processed during this configuration run 104 | if (${PREFIX}_FOUND) 105 | return() 106 | endif() 107 | 108 | set(found TRUE) # Start with the assumption that the package was found 109 | 110 | # Did we find any files? Did we miss includes? These are for formatting better error messages. 111 | set(some_files FALSE) 112 | set(missing_headers FALSE) 113 | 114 | # Shorthands for some variables that we need often 115 | set(quiet ${${PREFIX}_FIND_QUIETLY}) 116 | set(required ${${PREFIX}_FIND_REQUIRED}) 117 | set(exactver ${${PREFIX}_FIND_VERSION_EXACT}) 118 | set(findver "${${PREFIX}_FIND_VERSION}") 119 | set(version "${${PREFIX}_VERSION}") 120 | 121 | # Lists of config option names (all, includes, libs) 122 | unset(configopts) 123 | set(includeopts ${${PREFIX}_PROCESS_INCLUDES}) 124 | set(libraryopts ${${PREFIX}_PROCESS_LIBS}) 125 | 126 | # Process deps to add to 127 | foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES}) 128 | if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_OPTS) 129 | # The package seems to export option lists that we can use, woohoo! 130 | list(APPEND includeopts ${${i}_INCLUDE_OPTS}) 131 | list(APPEND libraryopts ${${i}_LIBRARY_OPTS}) 132 | else() 133 | # If plural forms don't exist or they equal singular forms 134 | if ((NOT DEFINED ${i}_INCLUDE_DIRS AND NOT DEFINED ${i}_LIBRARIES) OR 135 | ({i}_INCLUDE_DIR STREQUAL ${i}_INCLUDE_DIRS AND ${i}_LIBRARY STREQUAL ${i}_LIBRARIES)) 136 | # Singular forms can be used 137 | if (DEFINED ${i}_INCLUDE_DIR) 138 | list(APPEND includeopts ${i}_INCLUDE_DIR) 139 | endif() 140 | if (DEFINED ${i}_LIBRARY) 141 | list(APPEND libraryopts ${i}_LIBRARY) 142 | endif() 143 | else() 144 | # Oh no, we don't know the option names 145 | message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes and libs. Aieeh!") 146 | endif() 147 | endif() 148 | endforeach() 149 | 150 | if (includeopts) 151 | list(REMOVE_DUPLICATES includeopts) 152 | endif() 153 | 154 | if (libraryopts) 155 | list(REMOVE_DUPLICATES libraryopts) 156 | endif() 157 | 158 | string(REGEX REPLACE ".*[ ;]([^ ;]*(_INCLUDE_DIRS|_LIBRARIES))" "\\1" tmp "${includeopts} ${libraryopts}") 159 | if (NOT tmp STREQUAL "${includeopts} ${libraryopts}") 160 | message(AUTHOR_WARNING "Plural form ${tmp} found in config options of ${PREFIX}. This works as before but is now deprecated. Please only use singular forms INCLUDE_DIR and LIBRARY, and update your find scripts for LibFindMacros > 2.0 automatic dependency system (most often you can simply remove the PROCESS variables entirely).") 161 | endif() 162 | 163 | # Include/library names separated by spaces (notice: not CMake lists) 164 | unset(includes) 165 | unset(libs) 166 | 167 | # Process all includes and set found false if any are missing 168 | foreach (i ${includeopts}) 169 | list(APPEND configopts ${i}) 170 | if (NOT "${${i}}" STREQUAL "${i}-NOTFOUND") 171 | list(APPEND includes "${${i}}") 172 | else() 173 | set(found FALSE) 174 | set(missing_headers TRUE) 175 | endif() 176 | endforeach() 177 | 178 | # Process all libraries and set found false if any are missing 179 | foreach (i ${libraryopts}) 180 | list(APPEND configopts ${i}) 181 | if (NOT "${${i}}" STREQUAL "${i}-NOTFOUND") 182 | list(APPEND libs "${${i}}") 183 | else() 184 | set (found FALSE) 185 | endif() 186 | endforeach() 187 | 188 | # Version checks 189 | if (found AND findver) 190 | if (NOT version) 191 | message(WARNING "The find module for ${PREFIX} does not provide version information, so we'll just assume that it is OK. Please fix the module or remove package version requirements to get rid of this warning.") 192 | elseif (version VERSION_LESS findver OR (exactver AND NOT version VERSION_EQUAL findver)) 193 | set(found FALSE) 194 | set(version_unsuitable TRUE) 195 | endif() 196 | endif() 197 | 198 | # If all-OK, hide all config options, export variables, print status and exit 199 | if (found) 200 | foreach (i ${configopts}) 201 | mark_as_advanced(${i}) 202 | endforeach() 203 | if (NOT quiet) 204 | message(STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}") 205 | if (LIBFIND_DEBUG) 206 | message(STATUS " ${PREFIX}_DEPENDENCIES=${${PREFIX}_DEPENDENCIES}") 207 | message(STATUS " ${PREFIX}_INCLUDE_OPTS=${includeopts}") 208 | message(STATUS " ${PREFIX}_INCLUDE_DIRS=${includes}") 209 | message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}") 210 | message(STATUS " ${PREFIX}_LIBRARIES=${libs}") 211 | endif() 212 | set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE) 213 | set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE) 214 | set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE) 215 | set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE) 216 | set (${PREFIX}_FOUND TRUE PARENT_SCOPE) 217 | endif() 218 | return() 219 | endif() 220 | 221 | # Format messages for debug info and the type of error 222 | set(vars "Relevant CMake configuration variables:\n") 223 | foreach (i ${configopts}) 224 | mark_as_advanced(CLEAR ${i}) 225 | set(val ${${i}}) 226 | if ("${val}" STREQUAL "${i}-NOTFOUND") 227 | set (val "") 228 | elseif (val AND NOT EXISTS ${val}) 229 | set (val "${val} (does not exist)") 230 | else() 231 | set(some_files TRUE) 232 | endif() 233 | set(vars "${vars} ${i}=${val}\n") 234 | endforeach() 235 | set(vars "${vars}You may use CMake GUI, cmake -D or ccmake to modify the values. Delete CMakeCache.txt to discard all values and force full re-detection if necessary.\n") 236 | if (version_unsuitable) 237 | set(msg "${PREFIX} ${${PREFIX}_VERSION} was found but") 238 | if (exactver) 239 | set(msg "${msg} only version ${findver} is acceptable.") 240 | else() 241 | set(msg "${msg} version ${findver} is the minimum requirement.") 242 | endif() 243 | else() 244 | if (missing_headers) 245 | set(msg "We could not find development headers for ${PREFIX}. Do you have the necessary dev package installed?") 246 | elseif (some_files) 247 | set(msg "We only found some files of ${PREFIX}, not all of them. Perhaps your installation is incomplete or maybe we just didn't look in the right place?") 248 | if(findver) 249 | set(msg "${msg} This could also be caused by incompatible version (if it helps, at least ${PREFIX} ${findver} should work).") 250 | endif() 251 | else() 252 | set(msg "We were unable to find package ${PREFIX}.") 253 | endif() 254 | endif() 255 | 256 | # Fatal error out if REQUIRED 257 | if (required) 258 | set(msg "REQUIRED PACKAGE NOT FOUND\n${msg} This package is REQUIRED and you need to install it or adjust CMake configuration in order to continue building ${CMAKE_PROJECT_NAME}.") 259 | message(FATAL_ERROR "${msg}\n${vars}") 260 | endif() 261 | # Otherwise just print a nasty warning 262 | if (NOT quiet) 263 | message(WARNING "WARNING: MISSING PACKAGE\n${msg} This package is NOT REQUIRED and you may ignore this warning but by doing so you may miss some functionality of ${CMAKE_PROJECT_NAME}. \n${vars}") 264 | endif() 265 | endfunction() 266 | 267 | -------------------------------------------------------------------------------- /data/io.papyros.AppCenter.appdata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | io.papyros.AppCenter.desktop 5 | CC0-1.0 6 | GPL-3.0+ 7 | Papyros App Center 8 | Application manager for Ppayros 9 | 10 |

11 | App Center allows you to find and install new applications. 12 |

13 |
14 | 15 | 16 | 17 | 20 | 21 | 22 | 23 |

This is an initial development release

24 |
25 |
26 |
27 | 28 | 29 | 30 | http://papyros.io 31 | sonrisesoftware@gmail.com 32 | Papyros 33 |
34 | -------------------------------------------------------------------------------- /data/io.papyros.AppCenter.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=App Center 3 | Comment=App Center for Papyros 4 | Exec=papyros-appcenter 5 | Icon=software-store 6 | Terminal=False 7 | Type=Application 8 | Categories=Papyros;Apps 9 | -------------------------------------------------------------------------------- /data/io.papyros.AppCenter.notifyrc: -------------------------------------------------------------------------------- 1 | [Global] 2 | IconName=software-store 3 | Comment=App Center 4 | 5 | [Event/updatesAvailable] 6 | Name=Updates available 7 | Comment=Software Updates Available 8 | Action=Sound|Popup 9 | Sound=Blip.ogg 10 | -------------------------------------------------------------------------------- /declarative/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE SOURCES *.cpp *.h) 2 | file(GLOB_RECURSE QML_FILES *.qml) 3 | 4 | add_library(papyrossoftware SHARED ${SOURCES}) 5 | 6 | target_link_libraries(papyrossoftware 7 | Qt5::Core 8 | Qt5::Qml 9 | Papyros::Core 10 | Papyros::Software) 11 | 12 | install(TARGETS papyrossoftware 13 | DESTINATION ${QML_INSTALL_DIR}/Papyros/Software) 14 | install(FILES qmldir ${QML_FILES} 15 | DESTINATION ${QML_INSTALL_DIR}/Papyros/Software) 16 | -------------------------------------------------------------------------------- /declarative/plugin.cpp: -------------------------------------------------------------------------------- 1 | #include "plugin.h" 2 | 3 | #include "softwaremanager.h" 4 | #include "source.h" 5 | #include "application.h" 6 | #include "screenshot.h" 7 | 8 | void SoftwarePlugin::registerTypes(const char *uri) 9 | { 10 | // @uri Papyros.Material 11 | Q_ASSERT(uri == QStringLiteral("Papyros.Software")); 12 | 13 | qmlRegisterType(uri, 0, 1, "SoftwareManager"); 14 | qmlRegisterUncreatableType(uri, 0, 1, "SoftwareSource", "A remote for xdg-app"); 15 | qmlRegisterUncreatableType(uri, 0, 1, "Application", "An application for xdg-app"); 16 | qmlRegisterUncreatableType(uri, 0, 1, "Screenshot", "An screenshot for xdg-app"); 17 | } 18 | -------------------------------------------------------------------------------- /declarative/plugin.h: -------------------------------------------------------------------------------- 1 | #ifndef SOFTWARE_PLUGIN_H 2 | #define SOFTWARE_PLUGIN_H 3 | 4 | #include 5 | #include 6 | 7 | class SoftwarePlugin : public QQmlExtensionPlugin 8 | { 9 | Q_OBJECT 10 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") 11 | 12 | public: 13 | void registerTypes(const char *uri); 14 | }; 15 | 16 | #endif // SOFTWARE_PLUGIN_H 17 | -------------------------------------------------------------------------------- /declarative/qmldir: -------------------------------------------------------------------------------- 1 | module Papyros.Software 2 | plugin papyrossoftware 3 | -------------------------------------------------------------------------------- /framework/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(GenerateExportHeader) 2 | include(ECMPackageConfigHelpers) 3 | include(ECMSetupVersion) 4 | include(ECMGenerateHeaders) 5 | 6 | ecm_setup_version(${PROJECT_VERSION} VARIABLE_PREFIX SOFTWARE 7 | VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/software_version.h" 8 | PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/SoftwareConfigVersion.cmake" 9 | SOVERSION ${PROJECT_SOVERSION}) 10 | 11 | include_directories( 12 | ${CMAKE_BINARY_DIR}/headers 13 | ${CMAKE_CURRENT_BINARY_DIR} 14 | ) 15 | 16 | file(GLOB_RECURSE SOURCES *.cpp *.h) 17 | file(GLOB_RECURSE QML_FILES *.qml) 18 | 19 | add_library(PapyrosSoftware SHARED ${SOURCES}) 20 | 21 | generate_export_header(PapyrosSoftware BASE_NAME Software EXPORT_FILE_NAME software/software_export.h) 22 | add_library(Papyros::Software ALIAS PapyrosSoftware) 23 | 24 | target_link_libraries(PapyrosSoftware 25 | PUBLIC 26 | Qt5::Core 27 | Qt5::Gui 28 | Qt5::Xml 29 | Qt5::Concurrent 30 | Papyros::Core 31 | PRIVATE 32 | KF5::Archive 33 | ${XdgApp_LIBRARIES} 34 | ) 35 | 36 | include_directories(${XdgApp_INCLUDE_DIRS}) 37 | 38 | set(SOFTWARE_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/Papyros") 39 | 40 | target_include_directories(PapyrosSoftware INTERFACE "$") 41 | 42 | set_target_properties(PapyrosSoftware PROPERTIES VERSION ${PROJECT_VERSION} 43 | SOVERSION ${PROJECT_SOVERSION} 44 | EXPORT_NAME Software 45 | ) 46 | 47 | ecm_generate_headers(Software_CamelCase_HEADERS 48 | HEADER_NAMES 49 | SoftwareManager Application Source Screenshot 50 | PREFIX 51 | Software 52 | REQUIRED_HEADERS Software_HEADERS 53 | ) 54 | 55 | install(FILES ${Software_CamelCase_HEADERS} 56 | DESTINATION ${SOFTWARE_INCLUDEDIR}/Software 57 | COMPONENT Devel) 58 | 59 | install(TARGETS PapyrosSoftware EXPORT SoftwareTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) 60 | 61 | install( 62 | FILES 63 | ${CMAKE_CURRENT_BINARY_DIR}/software/software_export.h 64 | ${Software_HEADERS} 65 | DESTINATION 66 | ${SOFTWARE_INCLUDEDIR}/software 67 | COMPONENT 68 | Devel 69 | ) 70 | 71 | # Create a Config.cmake and a ConfigVersion.cmake file and install them 72 | set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/Papyros") 73 | 74 | ecm_configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/SoftwareConfig.cmake.in" 75 | "${CMAKE_CURRENT_BINARY_DIR}/SoftwareConfig.cmake" 76 | INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}) 77 | 78 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/SoftwareConfig.cmake" 79 | "${CMAKE_CURRENT_BINARY_DIR}/SoftwareConfigVersion.cmake" 80 | DESTINATION "${CMAKECONFIG_INSTALL_DIR}" 81 | COMPONENT Devel) 82 | 83 | install(EXPORT SoftwareTargets 84 | DESTINATION "${CMAKECONFIG_INSTALL_DIR}" 85 | FILE SoftwareTargets.cmake NAMESPACE Papyros::) 86 | 87 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/software_version.h 88 | DESTINATION ${SOFTWARE_INCLUDEDIR}/software COMPONENT Devel) 89 | -------------------------------------------------------------------------------- /framework/SoftwareConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | find_dependency(Qt5Core @QT_MIN_VERSION@) 4 | find_dependency(Qt5Gui @QT_MIN_VERSION@) 5 | find_dependency(Qt5Xml @QT_MIN_VERSION@) 6 | find_dependency(Qt5Concurrent @QT_MIN_VERSION@) 7 | find_dependency(KF5Archive @KF5_MIN_VERSION@) 8 | 9 | find_dependency(XdgApp) 10 | find_dependency(Papyros) 11 | 12 | include("${CMAKE_CURRENT_LIST_DIR}/SoftwareTargets.cmake") 13 | -------------------------------------------------------------------------------- /framework/application.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "application.h" 20 | 21 | #define REFINE_PROPERTY(name, value) \ 22 | if (!value.isNull()) \ 23 | name = value; 24 | #define REFINE_LIST_PROPERTY(name, value) name << value; 25 | 26 | void Application::refineFromAppstream(Appstream::Component component) 27 | { 28 | REFINE_PROPERTY(m_id, component.m_id); 29 | REFINE_PROPERTY(m_name, component.name()); 30 | REFINE_PROPERTY(m_summary, component.comment()); 31 | REFINE_PROPERTY(m_icon, component.m_icon); 32 | 33 | foreach (Appstream::Screenshot screenshot, component.m_screenshots) { 34 | m_screenshots << new Screenshot(screenshot, this); 35 | } 36 | } 37 | 38 | bool Application::launch() const 39 | { 40 | if (m_state != Application::Installed) 41 | return false; 42 | 43 | return m_backend->launchApplication(this); 44 | } 45 | -------------------------------------------------------------------------------- /framework/application.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef APPLICATION_H 20 | #define APPLICATION_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #include 29 | 30 | #include "appstream/component.h" 31 | #include "appstream/screenshot.h" 32 | #include "backend.h" 33 | #include "screenshot.h" 34 | 35 | class SOFTWARE_EXPORT Application : public QObject 36 | { 37 | Q_OBJECT 38 | 39 | Q_PROPERTY(State state MEMBER m_state CONSTANT) 40 | Q_PROPERTY(Type type MEMBER m_type CONSTANT) 41 | Q_PROPERTY(QString id MEMBER m_id CONSTANT) 42 | Q_PROPERTY(QString name MEMBER m_name CONSTANT) 43 | Q_PROPERTY(QString summary MEMBER m_summary CONSTANT) 44 | Q_PROPERTY(QIcon icon READ icon CONSTANT) 45 | Q_PROPERTY(QString latestVersion READ latestVersion CONSTANT) 46 | Q_PROPERTY(QString installedVersion READ installedVersion CONSTANT) 47 | Q_PROPERTY(QObjectListModel *screenshots READ screenshots CONSTANT) 48 | Q_PROPERTY(bool updatesAvailable READ updatesAvailable CONSTANT) 49 | 50 | public: 51 | enum State 52 | { 53 | Installed, 54 | Available 55 | }; 56 | Q_ENUM(State) 57 | 58 | enum Type 59 | { 60 | App, 61 | Runtime 62 | }; 63 | Q_ENUM(Type) 64 | 65 | Application(SoftwareBackend *backend) : QObject(backend), m_backend(backend) {} 66 | 67 | void refineFromAppstream(Appstream::Component component); 68 | 69 | virtual QString latestVersion() const = 0; 70 | virtual QString installedVersion() const = 0; 71 | virtual bool updatesAvailable() const = 0; 72 | 73 | QObjectListModel *screenshots() { return m_screenshots.getModel(); } 74 | 75 | QIcon icon() 76 | { 77 | if (m_icon.isNull()) 78 | return QIcon::fromTheme("application-x-executable"); 79 | else 80 | return m_icon; 81 | } 82 | 83 | State m_state; 84 | Type m_type; 85 | QString m_id; 86 | QString m_name; 87 | QString m_summary; 88 | QIcon m_icon; 89 | QQuickList m_screenshots; 90 | 91 | public slots: 92 | bool launch() const; 93 | 94 | private: 95 | SoftwareBackend *m_backend; 96 | }; 97 | 98 | #endif // APPLICATION_H 99 | -------------------------------------------------------------------------------- /framework/appstream/component.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * Copyright (C) 2013-2015 Richard Hughes 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #include "component.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "utils.h" 30 | #include "store.h" 31 | 32 | #define MERGE_FIELD(other, fieldName) \ 33 | if (fieldName.isNull()) \ 34 | fieldName = other.fieldName; 35 | #define MERGE_LIST_FIELD(other, fieldName) mergeLists(fieldName, other.fieldName); 36 | #define MERGE_HASH_FIELD(other, fieldName) mergeHashes(fieldName, other.fieldName); 37 | 38 | using namespace Appstream; 39 | 40 | QString defaultLocale() { return QLocale::system().name(); } 41 | 42 | template 43 | T lookupLocale(QHash hash, QString locale) 44 | { 45 | QStringList locales = {QLocale::system().name(), QLocale::c().name()}; 46 | if (!locale.isEmpty()) 47 | locales.insert(0, locale); 48 | foreach (QString possibleLocale, locales) { 49 | if (hash.contains(possibleLocale)) 50 | return hash[possibleLocale]; 51 | } 52 | return T(); 53 | } 54 | 55 | template 56 | void removeItems(QList *list, QList sublist) 57 | { 58 | Q_FOREACH (T item, sublist) { 59 | list->removeAll(item); 60 | } 61 | } 62 | 63 | void Component::merge(const Component &other) 64 | { 65 | MERGE_FIELD(other, m_id); 66 | MERGE_FIELD(other, m_kind); 67 | if (m_priority == -1) 68 | m_priority = other.m_priority; 69 | MERGE_LIST_FIELD(other, m_packageNames); 70 | MERGE_LIST_FIELD(other, m_categories); 71 | MERGE_LIST_FIELD(other, m_architectures); 72 | MERGE_LIST_FIELD(other, m_kudos); 73 | MERGE_LIST_FIELD(other, m_permissions); 74 | MERGE_LIST_FIELD(other, m_vetos); 75 | MERGE_LIST_FIELD(other, m_mimetypes); 76 | MERGE_FIELD(other, m_projectLicense); 77 | MERGE_FIELD(other, m_metadataLicense); 78 | MERGE_FIELD(other, m_sourcePackageName); 79 | MERGE_FIELD(other, m_updateContact); 80 | MERGE_FIELD(other, m_projectGroup); 81 | MERGE_LIST_FIELD(other, m_compulsoryForDesktops); 82 | MERGE_LIST_FIELD(other, m_extends); 83 | MERGE_LIST_FIELD(other, m_urls); 84 | MERGE_HASH_FIELD(other, m_names); 85 | MERGE_HASH_FIELD(other, m_comments); 86 | MERGE_HASH_FIELD(other, m_developerNames); 87 | MERGE_HASH_FIELD(other, m_keywords); 88 | MERGE_FIELD(other, m_icon); 89 | MERGE_LIST_FIELD(other, m_screenshots); 90 | } 91 | 92 | bool Component::loadFromFile(QString filename) 93 | { 94 | switch (kindFromFilename(filename)) { 95 | case Appstream::Appdata: 96 | case Appstream::Metainfo: 97 | return loadFromAppdataFile(filename); 98 | case Appstream::Desktop: 99 | return loadFromDesktopFile(filename); 100 | default: 101 | return false; 102 | } 103 | } 104 | 105 | bool Component::loadFromAppdataFile(QString filename) 106 | { 107 | qDebug() << "Loading from appdata file!"; 108 | QDomDocument doc("appdata"); 109 | 110 | if (!loadDocumentFromFile(&doc, filename)) 111 | return false; 112 | 113 | QDomElement appNode = doc.firstChildElement("application"); 114 | if (appNode.isNull()) 115 | appNode = doc.firstChildElement("component"); 116 | if (appNode.isNull()) 117 | return false; 118 | 119 | return loadFromAppdata(appNode, ""); 120 | } 121 | 122 | bool Component::loadFromAppdata(QDomElement appNode, QString iconPath) 123 | { 124 | for (QDomNode node = appNode.firstChild(); !node.isNull(); node = node.nextSibling()) { 125 | QDomElement element = node.toElement(); 126 | 127 | if (element.isNull()) 128 | continue; 129 | 130 | QString tagName = element.tagName(); 131 | QString text = element.text(); 132 | 133 | // qDebug() << tagName << text; 134 | 135 | if (tagName == "id") { 136 | m_id = text; 137 | QString kind = element.attribute("type"); 138 | if (!kind.isEmpty()) 139 | m_kind = kind; 140 | } else if (tagName == "priority") { 141 | m_priority = text.toInt(); 142 | } else if (tagName == "pkgname") { 143 | m_packageNames << text; 144 | } else if (tagName == "bundle") { 145 | // TODO: Parse and add the bundle 146 | m_bundle = text; 147 | } else if (tagName == "name") { 148 | QString language = element.attribute("xml:lang"); 149 | if (language.isEmpty()) 150 | language = "C"; 151 | m_names[language] = text; 152 | } else if (tagName == "summary") { 153 | QString language = element.attribute("xml:lang"); 154 | if (language.isEmpty()) 155 | language = "C"; 156 | m_comments[language] = text; 157 | } else if (tagName == "developer_name") { 158 | QString language = element.attribute("xml:lang"); 159 | if (language.isEmpty()) 160 | language = "C"; 161 | m_developerNames[language] = text; 162 | } else if (tagName == "description") { 163 | qDebug() << "WARNING: description not parsed"; 164 | } else if (tagName == "icon") { 165 | QString fileName = iconPath + "/" + text; 166 | QSize size(element.attribute("width").toInt(), element.attribute("height").toInt()); 167 | m_icon.addFile(fileName, size); 168 | } else if (tagName == "categories") { 169 | m_categories << stringsByTagName(element, "category"); 170 | } else if (tagName == "architectures") { 171 | m_architectures << stringsByTagName(element, "architecture"); 172 | } else if (tagName == "keywords") { 173 | FOREACH_ELEMENT (QDomElement keyword, element.elementsByTagName("keyword")) { 174 | if (!keyword.isNull()) { 175 | QString language = element.attribute("xml:lang"); 176 | addKeyword(keyword.text(), language); 177 | } 178 | } 179 | } else if (tagName == "kudos") { 180 | m_kudos << stringsByTagName(element, "kudo"); 181 | } else if (tagName == "permissions") { 182 | m_permissions << stringsByTagName(element, "permission"); 183 | } else if (tagName == "vetos") { 184 | m_vetos << stringsByTagName(element, "veto"); 185 | } else if (tagName == "mimetypes") { 186 | m_mimetypes << stringsByTagName(element, "mimetype"); 187 | } else if (tagName == "project_license") { 188 | m_projectLicense = text; 189 | } else if (tagName == "metadata_license") { 190 | m_metadataLicense = text; 191 | } else if (tagName == "source_pkgname") { 192 | m_sourcePackageName = text; 193 | } else if (tagName == "updatecontact" || tagName == "update_contact") { 194 | m_updateContact = text; 195 | } else if (tagName == "url") { 196 | m_urls << Url(text, element.attribute("type")); 197 | } else if (tagName == "project_group") { 198 | m_projectGroup = text; 199 | } else if (tagName == "compulsory_for_desktop") { 200 | m_compulsoryForDesktops << text; 201 | } else if (tagName == "extends") { 202 | m_extends << text; 203 | } else if (tagName == "screenshots") { 204 | FOREACH_ELEMENT (QDomElement screenshot, element.elementsByTagName("screenshot")) { 205 | // TODO: New object created without parent 206 | if (!screenshot.isNull()) 207 | m_screenshots << Screenshot(screenshot); 208 | } 209 | m_screenshots << Screenshot(element); 210 | } else if (tagName == "releases") { 211 | qDebug() << "WARNING: releases not parsed"; 212 | } else if (tagName == "provides") { 213 | qDebug() << "WARNING: provides not parsed"; 214 | } else if (tagName == "languages") { 215 | qDebug() << "WARNING: languages not parsed"; 216 | } else if (tagName == "metadata") { 217 | qDebug() << "WARNING: metadata not parsed"; 218 | } else { 219 | qFatal("Tag not supported: %s", qPrintable(tagName)); 220 | } 221 | } 222 | 223 | return true; 224 | } 225 | 226 | bool Component::loadFromDesktopFile(QString filename) 227 | { 228 | QFileInfo fileInfo(filename); 229 | 230 | m_id = fileInfo.fileName(); 231 | 232 | QSettings settings(filename, QSettings::IniFormat); 233 | 234 | settings.beginGroup("Desktop Entry"); 235 | 236 | Q_FOREACH (QString key, settings.allKeys()) { 237 | QString value = settings.value(key).toString(); 238 | 239 | // qDebug() << key << value; 240 | 241 | if (key == "NoDisplay") { 242 | if (value == "True") 243 | m_vetos << "NoDisplay=true"; 244 | } else if (key == "Type") { 245 | if (value != "Application") 246 | return false; 247 | } else if (key == "Icon") { 248 | QFileInfo info(value); 249 | 250 | if (info.isAbsolute()) { 251 | m_icon.addFile(value); 252 | } else { 253 | if (hasSuffix(value, {"png", "xpm", "svg"})) 254 | value = info.completeBaseName(); 255 | m_icon = QIcon::fromTheme(value); 256 | } 257 | } else if (key == "Categories") { 258 | QStringList categories = value.split(";"); 259 | QStringList ignoredCategories = {"GTK", "Qt", "KDE", "GNOME"}; 260 | removeItems(&categories, ignoredCategories); 261 | m_categories << categories; 262 | } else if (key == "Keywords") { 263 | qDebug() << "WARNING: Name skipped"; 264 | } else if (key == "MimeType") { 265 | qDebug() << "WARNING: Name skipped"; 266 | } else if (key == "OnlyShowIn") { 267 | QStringList desktops = value.split(";"); 268 | if (desktops.count() == 1) 269 | m_projectGroup = desktops[0]; 270 | } else if (key == "Name" || key == "_Name") { 271 | m_names["C"] = value; 272 | } else if (key.startsWith("Name")) { 273 | qDebug() << "WARNING: Name skipped"; 274 | } else if (key == "Comment" || key == "_Comment") { 275 | m_comments["C"] = value; 276 | } else if (key.startsWith("Comment")) { 277 | qDebug() << "WARNING: Comment skipped"; 278 | } else if (key == "X-AppInstall-Package") { 279 | m_packageNames << value; 280 | } else if (key == "X-Ubuntu-Software-Center-Name") { 281 | m_names["C"] = value; 282 | } else if (key.startsWith("X-Ubuntu-Software-Center-Name")) { 283 | qDebug() << "WARNING: X-Ubuntu-Software-Center-Name skipped"; 284 | } 285 | } 286 | 287 | settings.endGroup(); 288 | 289 | return true; 290 | } 291 | 292 | void Component::addKeyword(QString keyword, QString locale) 293 | { 294 | QStringList keywords = m_keywords.contains(locale) ? m_keywords[locale] : QStringList(); 295 | 296 | keywords << keyword; 297 | 298 | m_keywords[locale] = keywords; 299 | } 300 | 301 | QString Component::name(QString locale) const { return lookupLocale(m_names, locale); } 302 | 303 | QString Component::comment(QString locale) const { return lookupLocale(m_comments, locale); } 304 | 305 | QString Component::developerName(QString locale) const 306 | { 307 | return lookupLocale(m_developerNames, locale); 308 | } 309 | 310 | QStringList Component::keywords(QString locale) const { return lookupLocale(m_keywords, locale); } 311 | -------------------------------------------------------------------------------- /framework/appstream/component.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * Copyright (C) 2013-2015 Richard Hughes 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef COMPONENT_H 21 | #define COMPONENT_H 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "url.h" 31 | #include "screenshot.h" 32 | 33 | namespace Appstream 34 | { 35 | 36 | class Component 37 | { 38 | friend class Store; 39 | 40 | public: 41 | void merge(const Component &other); 42 | 43 | bool loadFromFile(QString filename); 44 | 45 | bool isNull() const { return m_id.isEmpty(); } 46 | QString name(QString locale = "") const; 47 | QString comment(QString locale = "") const; 48 | QString developerName(QString locale = "") const; 49 | QStringList keywords(QString locale = "") const; 50 | 51 | QString m_id; 52 | QString m_kind; 53 | QString m_bundle; 54 | int m_priority = -1; 55 | QStringList m_packageNames; 56 | QStringList m_categories; 57 | QStringList m_architectures; 58 | QStringList m_kudos; 59 | QStringList m_permissions; 60 | QStringList m_vetos; 61 | QStringList m_mimetypes; 62 | QString m_projectLicense; 63 | QString m_metadataLicense; 64 | QString m_sourcePackageName; 65 | QString m_updateContact; 66 | QString m_projectGroup; 67 | QStringList m_compulsoryForDesktops; 68 | QStringList m_extends; 69 | QList m_urls; 70 | QList m_screenshots; 71 | QIcon m_icon; 72 | 73 | private: 74 | bool loadFromAppdataFile(QString filename); 75 | bool loadFromDesktopFile(QString filename); 76 | 77 | bool loadFromAppdata(QDomElement element, QString iconPath); 78 | 79 | void addKeyword(QString keyword, QString locale); 80 | 81 | QHash m_names; 82 | QHash m_comments; 83 | QHash m_developerNames; 84 | QHash m_keywords; 85 | }; 86 | } 87 | 88 | #endif // COMPONENT_H 89 | -------------------------------------------------------------------------------- /framework/appstream/screenshot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * Copyright (C) 2013-2015 Richard Hughes 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #include "screenshot.h" 21 | 22 | #include "utils.h" 23 | 24 | #include 25 | 26 | using namespace Appstream; 27 | 28 | Screenshot::Screenshot(QDomElement element) 29 | { 30 | QStringList images = stringsByTagName(element, "image"); 31 | if (!images.isEmpty()) 32 | m_url = images.first(); 33 | else 34 | m_url = element.text(); 35 | 36 | QString type = element.attribute("type"); 37 | 38 | if (type == "default") 39 | m_type = Screenshot::Default; 40 | else if (type == "normal") 41 | m_type = Screenshot::Normal; 42 | else 43 | m_type = Screenshot::Unknown; 44 | } 45 | 46 | bool Screenshot::operator==(const Screenshot &other) const 47 | { 48 | return m_type == other.m_type && m_url == other.m_url; 49 | } 50 | -------------------------------------------------------------------------------- /framework/appstream/screenshot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * Copyright (C) 2013-2015 Richard Hughes 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef APPSTREAM_SCREENSHOT_H 21 | #define APPSTREAM_SCREENSHOT_H 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace Appstream 30 | { 31 | 32 | class Screenshot 33 | { 34 | 35 | public: 36 | enum Type 37 | { 38 | Normal, 39 | Default, 40 | Unknown 41 | }; 42 | 43 | Screenshot(QDomElement element); 44 | 45 | bool operator==(const Screenshot &other) const; 46 | 47 | QString m_url; 48 | Type m_type; 49 | int m_priority; 50 | QHash m_captions; 51 | }; 52 | } 53 | 54 | #endif // APPSTREAM_SCREENSHOT_H 55 | -------------------------------------------------------------------------------- /framework/appstream/store.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "store.h" 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | #include "utils.h" 27 | 28 | using namespace Appstream; 29 | 30 | SourceKind Appstream::kindFromFilename(QString filename) 31 | { 32 | if (hasSuffix(filename, {"xml.gz", "yml", "yml.gz"})) 33 | return Appstream::Appstream; 34 | else if (hasSuffix(filename, {"appdata.xml", "appdata.xml.in", "xml"})) 35 | return Appstream::Appdata; 36 | else if (hasSuffix(filename, {"metainfo.xml", "metainfo.xml.in"})) 37 | return Appstream::Metainfo; 38 | else if (hasSuffix(filename, {"desktop", "desktop.in"})) 39 | return Appstream::Desktop; 40 | else 41 | return Appstream::Unknown; 42 | } 43 | 44 | bool Store::load(QString path) 45 | { 46 | QDir dir(path); 47 | 48 | if (!dir.exists()) 49 | return false; 50 | 51 | Q_FOREACH (QString filename, dir.entryList()) { 52 | switch (kindFromFilename(filename)) { 53 | case Appstream::Appstream: 54 | loadFromAppstreamFile(path + "/" + filename, path + "/icons"); 55 | break; 56 | default: 57 | Component component; 58 | 59 | if (!component.loadFromFile(path + "/" + filename)) 60 | continue; 61 | 62 | addComponent(component); 63 | 64 | break; 65 | } 66 | } 67 | 68 | return true; 69 | } 70 | 71 | bool Store::loadFromAppstreamFile(QString filename, QString iconPath) 72 | { 73 | qDebug() << "Loading from appstream file" << filename; 74 | QDomDocument doc("appstream"); 75 | 76 | KCompressionDevice file(filename, KCompressionDevice::GZip); 77 | 78 | if (!file.open(QIODevice::ReadOnly)) 79 | return false; 80 | if (!doc.setContent(&file)) { 81 | file.close(); 82 | qWarning() << "Unable to read from file:" << filename; 83 | return false; 84 | } 85 | file.close(); 86 | 87 | QDomElement root = doc.firstChildElement("components"); 88 | if (root.isNull()) 89 | return false; 90 | 91 | FOREACH_ELEMENT (QDomElement element, root.elementsByTagName("component")) { 92 | Component component; 93 | 94 | if (!component.loadFromAppdata(element, iconPath)) 95 | continue; 96 | 97 | addComponent(component); 98 | } 99 | 100 | return true; 101 | } 102 | 103 | void Store::addComponent(Component component) 104 | { 105 | bool foundExisting = false; 106 | 107 | for (int i = 0; i < m_components.count(); i++) { 108 | Component &existingComponent = m_components[i]; 109 | 110 | if (existingComponent.m_id == component.m_id) { 111 | existingComponent.merge(component); 112 | foundExisting = true; 113 | } 114 | } 115 | 116 | if (!foundExisting) 117 | m_components << component; 118 | } 119 | 120 | Component Store::componentById(QString id) const 121 | { 122 | Q_FOREACH (Component component, m_components) { 123 | if (component.m_id == id) 124 | return component; 125 | } 126 | 127 | return Component(); 128 | } 129 | -------------------------------------------------------------------------------- /framework/appstream/store.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef STORE_H 20 | #define STORE_H 21 | 22 | #include 23 | 24 | #include "component.h" 25 | 26 | namespace Appstream 27 | { 28 | 29 | enum SourceKind 30 | { 31 | Appstream, 32 | Appdata, 33 | Metainfo, 34 | Desktop, 35 | Unknown 36 | }; 37 | 38 | SourceKind kindFromFilename(QString filename); 39 | 40 | class Store 41 | { 42 | 43 | public: 44 | bool load(QString path); 45 | 46 | Component componentById(QString id) const; 47 | 48 | QList allComponents() const { return m_components; } 49 | 50 | private: 51 | void addComponent(Component component); 52 | bool loadFromAppstreamFile(QString filename, QString iconPath); 53 | 54 | QList m_components; 55 | }; 56 | } 57 | 58 | #endif // STORE_H 59 | -------------------------------------------------------------------------------- /framework/appstream/url.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * Copyright (C) 2013-2015 Richard Hughes 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #include "url.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | using namespace Appstream; 29 | 30 | 31 | Url::Url(QString url, Type type) 32 | : m_url(url), m_type(type) 33 | { 34 | // Nothing needed here 35 | } 36 | 37 | Url::Url(QString url, QString type) 38 | : m_url(url) 39 | { 40 | if (type == "homepage") 41 | m_type = Url::Homepage; 42 | else if (type == "bugtracker") 43 | m_type = Url::BugTracker; 44 | else if (type == "faq") 45 | m_type = Url::FAQ; 46 | else if (type == "donation") 47 | m_type = Url::Donation; 48 | else if (type == "help") 49 | m_type = Url::Help; 50 | else if (type == "missing") 51 | m_type = Url::Missing; 52 | else 53 | m_type = Url::Unknown; 54 | } 55 | 56 | bool Url::operator==(const Url &other) const 57 | { 58 | return m_type == other.m_type && m_url == other.m_url; 59 | } 60 | -------------------------------------------------------------------------------- /framework/appstream/url.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * Copyright (C) 2013-2015 Richard Hughes 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef URL_H 21 | #define URL_H 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace Appstream 28 | { 29 | 30 | class Url 31 | { 32 | public: 33 | enum Type { 34 | Homepage, BugTracker, FAQ, Donation, Help, Missing, Unknown 35 | }; 36 | 37 | Url(QString url, Type type); 38 | Url(QString url, QString type); 39 | 40 | bool operator==(const Url &other) const; 41 | 42 | QString m_url; 43 | Type m_type; 44 | }; 45 | 46 | } 47 | 48 | #endif // URL_H 49 | -------------------------------------------------------------------------------- /framework/autocast.h: -------------------------------------------------------------------------------- 1 | #ifndef AUTOCAST_H 2 | #define AUTOCAST_H 3 | 4 | #include 5 | 6 | template 7 | class auto_cast_wrapper 8 | { 9 | public: 10 | template 11 | friend auto_cast_wrapper auto_cast(const R &x); 12 | 13 | template 14 | operator U() 15 | { 16 | return static_cast(mX); 17 | } 18 | 19 | private: 20 | auto_cast_wrapper(const T &x) : mX(x) {} 21 | 22 | auto_cast_wrapper(const auto_cast_wrapper &other) : mX(other.mX) {} 23 | 24 | // non-assignable 25 | auto_cast_wrapper &operator=(const auto_cast_wrapper &); 26 | 27 | const T &mX; 28 | }; 29 | 30 | template 31 | auto_cast_wrapper auto_cast(const R &x) 32 | { 33 | return auto_cast_wrapper(x); 34 | } 35 | 36 | template 37 | class explicit_cast_wrapper 38 | { 39 | public: 40 | template 41 | friend explicit_cast_wrapper explicit_cast(R &&x); 42 | 43 | template 44 | operator U() const 45 | { 46 | // doesn't allow downcasts, otherwise acts like static_cast 47 | // see: http://stackoverflow.com/questions/5693432/making-auto-cast-safe 48 | return U{std::forward(mX)}; 49 | } 50 | 51 | private: 52 | explicit_cast_wrapper(T &&x) : mX(std::forward(x)) {} 53 | 54 | explicit_cast_wrapper(const explicit_cast_wrapper &other) : mX(std::forward(other.mX)) {} 55 | 56 | explicit_cast_wrapper &operator=(const explicit_cast_wrapper &) = delete; 57 | 58 | T &&mX; 59 | }; 60 | 61 | template 62 | explicit_cast_wrapper explicit_cast(R &&x) 63 | { 64 | return explicit_cast_wrapper(std::forward(x)); 65 | } 66 | 67 | #endif // AUTOCAST_H 68 | -------------------------------------------------------------------------------- /framework/backend.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef BACKEND_H 20 | #define BACKEND_H 21 | 22 | #include 23 | 24 | class Application; 25 | class SoftwareSource; 26 | 27 | class SoftwareBackend : public QObject 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | SoftwareBackend(QObject *parent = nullptr) : QObject(parent) {} 33 | 34 | virtual QList listSources() = 0; 35 | virtual QList listInstalledApplications() = 0; 36 | virtual QList listAvailableApplications() = 0; 37 | 38 | public slots: 39 | virtual bool launchApplication(const Application *app) = 0; 40 | virtual bool downloadUpdates() = 0; 41 | virtual bool refreshAvailableApplications() = 0; 42 | 43 | signals: 44 | void updated(); 45 | void availableApplicationsChanged(); 46 | }; 47 | 48 | #endif // BACKEND_H 49 | -------------------------------------------------------------------------------- /framework/screenshot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * Copyright (C) 2013-2015 Richard Hughes 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #include "screenshot.h" 21 | 22 | #include "utils.h" 23 | 24 | #include 25 | 26 | Screenshot::Screenshot(Appstream::Screenshot screenshot, QObject *parent) : QObject(parent) 27 | { 28 | m_url = screenshot.m_url; 29 | m_type = screenshot.m_type; 30 | m_priority = screenshot.m_priority; 31 | m_captions = screenshot.m_captions; 32 | } 33 | -------------------------------------------------------------------------------- /framework/screenshot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * Copyright (C) 2013-2015 Richard Hughes 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef SCREENSHOT_H 21 | #define SCREENSHOT_H 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | #include "appstream/screenshot.h" 32 | 33 | class SOFTWARE_EXPORT Screenshot : public QObject 34 | { 35 | Q_OBJECT 36 | 37 | Q_PROPERTY(QString url MEMBER m_url CONSTANT) 38 | Q_PROPERTY(Type type MEMBER m_type CONSTANT) 39 | Q_PROPERTY(int priority MEMBER m_priority CONSTANT) 40 | 41 | public: 42 | typedef Appstream::Screenshot::Type Type; 43 | Q_ENUM(Type) 44 | 45 | Screenshot(Appstream::Screenshot, QObject *parent = nullptr); 46 | 47 | // bool operator==(const Screenshot &other) const; 48 | 49 | QString m_url; 50 | Type m_type; 51 | int m_priority; 52 | QHash m_captions; 53 | }; 54 | 55 | #endif // SCREENSHOT_H 56 | -------------------------------------------------------------------------------- /framework/softwaremanager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | #include "softwaremanager.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "xdg-app/xdg-backend.h" 26 | #include "source.h" 27 | #include "application.h" 28 | 29 | SoftwareManager::SoftwareManager(QObject *parent) : QObject(parent) 30 | { 31 | m_backends << new XdgAppBackend(this); 32 | 33 | foreach (SoftwareBackend *backend, m_backends) { 34 | // TODO: Only update the data from this backend instead of all backends 35 | QObject::connect(backend, &SoftwareBackend::updated, this, &SoftwareManager::update); 36 | QObject::connect(backend, &SoftwareBackend::availableApplicationsChanged, this, 37 | &SoftwareManager::availableApplicationsChanged); 38 | } 39 | 40 | QObject::connect(this, &SoftwareManager::updatesDownloaded, this, &SoftwareManager::update); 41 | } 42 | 43 | void SoftwareManager::refresh() 44 | { 45 | update(); 46 | availableApplicationsChanged(); 47 | 48 | refreshAvailableApps(); 49 | } 50 | 51 | void SoftwareManager::downloadUpdates() 52 | { 53 | QtConcurrent::run([this]() { 54 | foreach (SoftwareBackend *backend, m_backends) { 55 | backend->downloadUpdates(); 56 | } 57 | 58 | emit updatesDownloaded(); 59 | }); 60 | } 61 | 62 | void SoftwareManager::refreshAvailableApps() 63 | { 64 | QtConcurrent::run([this]() { 65 | foreach (SoftwareBackend *backend, m_backends) { 66 | backend->refreshAvailableApplications(); 67 | } 68 | }); 69 | } 70 | 71 | void SoftwareManager::availableApplicationsChanged() 72 | { 73 | m_availableApps.clear(); 74 | 75 | foreach (SoftwareBackend *backend, m_backends) { 76 | m_availableApps << backend->listAvailableApplications(); 77 | } 78 | 79 | emit updated(); 80 | } 81 | 82 | void SoftwareManager::update() 83 | { 84 | // TODO: Update the lists so only new objects are added and old objects removed 85 | m_sources.clear(); 86 | m_installedApps.clear(); 87 | m_availableUpdates.clear(); 88 | 89 | foreach (SoftwareBackend *backend, m_backends) { 90 | m_sources << backend->listSources(); 91 | m_installedApps << backend->listInstalledApplications(); 92 | } 93 | 94 | QList apps = m_installedApps; 95 | 96 | foreach (Application *app, apps) { 97 | if (app->updatesAvailable() && app->m_type == Application::App) 98 | m_availableUpdates << app; 99 | } 100 | 101 | emit updated(); 102 | } 103 | 104 | QString SoftwareManager::updatesSummary() const 105 | { 106 | if (m_availableUpdates.count() == 0) { 107 | return tr("No updates are available"); 108 | } else if (m_availableUpdates.count() == 1) { 109 | return tr("%1 is ready to update").arg(m_availableUpdates[0]->m_name); 110 | } else if (m_availableUpdates.count() == 2) { 111 | return tr("%1 and %2 are ready to update") 112 | .arg(m_availableUpdates[0]->m_name) 113 | .arg(m_availableUpdates[1]->m_name); 114 | } else if (m_availableUpdates.count() == 3) { 115 | return tr("%1, %2, and one other app are ready to update") 116 | .arg(m_availableUpdates[0]->m_name) 117 | .arg(m_availableUpdates[1]->m_name); 118 | } else { 119 | int otherCount = m_availableUpdates.count() - 2; 120 | 121 | return tr("%1, %2, and %3 other apps are ready to update") 122 | .arg(m_availableUpdates[0]->m_name) 123 | .arg(m_availableUpdates[1]->m_name) 124 | .arg(otherCount); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /framework/softwaremanager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SOFTWARE_H 20 | #define SOFTWARE_H 21 | 22 | #include 23 | 24 | #include 25 | 26 | #include 27 | 28 | class Application; 29 | class SoftwareSource; 30 | class SoftwareBackend; 31 | 32 | class SOFTWARE_EXPORT SoftwareManager : public QObject 33 | { 34 | Q_OBJECT 35 | 36 | Q_PROPERTY(QObjectListModel *sources READ sources CONSTANT) 37 | Q_PROPERTY(QObjectListModel *availableApps READ availableApps CONSTANT) 38 | Q_PROPERTY(QObjectListModel *availableUpdates READ availableUpdates CONSTANT) 39 | Q_PROPERTY(QObjectListModel *installedApps READ installedApps CONSTANT) 40 | Q_PROPERTY(bool hasUpdates READ hasUpdates NOTIFY updated) 41 | Q_PROPERTY(QString updatesSummary READ updatesSummary NOTIFY updated) 42 | 43 | public: 44 | SoftwareManager(QObject *parent = nullptr); 45 | 46 | QObjectListModel *sources() { return m_sources.getModel(); } 47 | 48 | QObjectListModel *availableApps() { return m_availableApps.getModel(); } 49 | QObjectListModel *availableUpdates() { return m_availableUpdates.getModel(); } 50 | 51 | QObjectListModel *installedApps() { return m_installedApps.getModel(); } 52 | 53 | bool hasUpdates() const { return m_availableUpdates.count() > 0; } 54 | 55 | QString updatesSummary() const; 56 | 57 | public slots: 58 | void refresh(); 59 | void downloadUpdates(); 60 | void refreshAvailableApps(); 61 | 62 | private slots: 63 | void update(); 64 | void availableApplicationsChanged(); 65 | 66 | signals: 67 | void updatesDownloaded(); 68 | void updated(); 69 | 70 | private: 71 | QList m_backends; 72 | QQuickList m_sources; 73 | QQuickList m_availableApps; 74 | QQuickList m_availableUpdates; 75 | QQuickList m_installedApps; 76 | }; 77 | 78 | #endif // SOFTWARE_H 79 | -------------------------------------------------------------------------------- /framework/source.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef SOURCE_H 20 | #define SOURCE_H 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | class SOFTWARE_EXPORT SoftwareSource : public QObject 28 | { 29 | Q_OBJECT 30 | 31 | Q_PROPERTY(QString name MEMBER m_name CONSTANT) 32 | Q_PROPERTY(QString title MEMBER m_title CONSTANT) 33 | Q_PROPERTY(QString url MEMBER m_url CONSTANT) 34 | 35 | public: 36 | SoftwareSource(QObject *parent = nullptr) : QObject(parent) {} 37 | 38 | QString m_name; 39 | QString m_title; 40 | QString m_url; 41 | }; 42 | 43 | #endif // SOURCE_H 44 | -------------------------------------------------------------------------------- /framework/utils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "utils.h" 20 | 21 | #include 22 | 23 | QStringList stringsByTagName(QDomElement element, QString tagName) 24 | { 25 | QStringList strings; 26 | 27 | QDomNodeList nodes = element.elementsByTagName(tagName); 28 | for (int i = 0; i < nodes.count(); i++) { 29 | QDomElement subElement = nodes.at(i).toElement(); 30 | if (!subElement.isNull()) 31 | strings << subElement.text(); 32 | } 33 | 34 | return strings; 35 | } 36 | 37 | bool loadDocumentFromFile(QDomDocument *document, QString filename) 38 | { 39 | QFile file(filename); 40 | 41 | if (!file.open(QIODevice::ReadOnly)) 42 | return false; 43 | if (!document->setContent(&file)) { 44 | file.close(); 45 | return false; 46 | } 47 | file.close(); 48 | return true; 49 | } 50 | 51 | bool hasSuffix(QString filename, QStringList suffices) 52 | { 53 | foreach (QString suffix, suffices) { 54 | if (filename.endsWith(suffix)) 55 | return true; 56 | } 57 | 58 | return false; 59 | } 60 | -------------------------------------------------------------------------------- /framework/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef APPSTREAM_UTILS_H 20 | #define APPSTREAM_UTILS_H 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | #include "autocast.h" 28 | 29 | #define G_FOREACH(item, array) \ 30 | for (uint keep = 1, index = 0; keep && index < (array)->len; keep = !keep, index++) \ 31 | for (item = auto_cast(g_ptr_array_index(array, index)); keep; keep = !keep) 32 | 33 | #define FOREACH_ELEMENT(item, list) \ 34 | for (uint keep = 1, index = 0; keep && index < static_cast((list).count()); \ 35 | keep = !keep, index++) \ 36 | for (item = (list).at(index).toElement(); keep; keep = !keep) 37 | 38 | QStringList stringsByTagName(QDomElement element, QString tagName); 39 | 40 | bool loadDocumentFromFile(QDomDocument *document, QString filename); 41 | 42 | bool hasSuffix(QString filename, QStringList suffices); 43 | 44 | template 45 | void mergeLists(QList &list1, const QList &list2) 46 | { 47 | foreach (T item, list2) { 48 | if (!list1.contains(item)) 49 | list1 << item; 50 | } 51 | } 52 | 53 | template 54 | void mergeHashes(QHash> &hash1, const QHash> &hash2) 55 | { 56 | foreach (T key, hash2.keys()) { 57 | if (hash1.contains(key)) 58 | hash1[key] << hash2[key]; 59 | else 60 | hash1[key] = hash2[key]; 61 | } 62 | } 63 | 64 | template 65 | void mergeHashes(QHash &hash1, const QHash &hash2) 66 | { 67 | foreach (T key, hash2.keys()) { 68 | if (!hash1.contains(key)) 69 | hash1[key] = hash2[key]; 70 | } 71 | } 72 | 73 | #endif // APPSTREAM_UTILS_H 74 | -------------------------------------------------------------------------------- /framework/xdg-app/base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #undef signals 20 | extern "C" { 21 | #include 22 | } 23 | #define signals Q_SIGNALS 24 | -------------------------------------------------------------------------------- /framework/xdg-app/xdg-application.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * Copyright (C) 2015 Richard Hughes 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #include "xdg-application.h" 21 | 22 | #include "appstream/store.h" 23 | 24 | XdgApplication::XdgApplication(XdgAppInstalledRef *app_ref, SoftwareBackend *backend) 25 | : Application(backend) 26 | { 27 | m_state = Application::Installed; 28 | m_id = xdg_app_ref_get_name(XDG_APP_REF(app_ref)); 29 | m_branch = xdg_app_ref_get_branch(XDG_APP_REF(app_ref)); 30 | m_origin = xdg_app_installed_ref_get_origin(app_ref); 31 | m_name = m_id; 32 | m_arch = xdg_app_ref_get_arch(XDG_APP_REF(app_ref)); 33 | 34 | m_currentCommit = xdg_app_ref_get_commit(XDG_APP_REF(app_ref)); 35 | m_latestCommit = xdg_app_installed_ref_get_latest_commit(app_ref); 36 | 37 | if (m_branch.isEmpty()) 38 | m_branch = "master"; 39 | 40 | QString desktopId; 41 | 42 | switch (xdg_app_ref_get_kind(XDG_APP_REF(app_ref))) { 43 | case XDG_APP_REF_KIND_APP: 44 | m_type = Application::App; 45 | 46 | desktopId = m_name + ".desktop"; 47 | break; 48 | case XDG_APP_REF_KIND_RUNTIME: 49 | m_type = Application::Runtime; 50 | m_icon = QIcon::fromTheme("package-x-generic"); 51 | m_summary = "Framework for applications"; 52 | 53 | desktopId = m_name + ".runtime"; 54 | break; 55 | default: 56 | // TODO: Handle errors here! 57 | break; 58 | } 59 | 60 | QString deployDir = xdg_app_installed_ref_get_deploy_dir(app_ref); 61 | QString desktopPath = deployDir + "/files/share/applications"; 62 | QString appdataPath = deployDir + "/files/share/appdata"; 63 | 64 | Appstream::Store store; 65 | store.load(desktopPath); 66 | store.load(appdataPath); 67 | 68 | Appstream::Component component = store.componentById(desktopId); 69 | if (!component.isNull()) 70 | refineFromAppstream(component); 71 | } 72 | 73 | XdgApplication::XdgApplication(Appstream::Component component, QString origin, 74 | SoftwareBackend *backend) 75 | : Application(backend) 76 | { 77 | m_state = Application::Available; 78 | m_origin = origin; 79 | 80 | QStringList bundle = component.m_bundle.split('/'); 81 | 82 | m_branch = bundle[bundle.length() - 1]; 83 | m_arch = bundle[bundle.length() - 2]; 84 | 85 | refineFromAppstream(component); 86 | } 87 | 88 | void XdgApplication::install() 89 | { 90 | /* install */ 91 | // xref = xdg_app_installation_install (plugin->priv->installation, 92 | // gs_app_get_origin (app), 93 | // XDG_APP_REF_KIND_APP, 94 | // gs_app_get_id (app), 95 | // gs_app_get_metadata_item (app, "XgdApp::arch"), 96 | // gs_app_get_metadata_item (app, "XgdApp::branch"), 97 | // gs_plugin_xdg_app_progress_cb, &helper, 98 | // cancellable, error); 99 | } 100 | -------------------------------------------------------------------------------- /framework/xdg-app/xdg-application.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XDG_APPLICATION_H 20 | #define XDG_APPLICATION_H 21 | 22 | #include "application.h" 23 | 24 | #include 25 | #include 26 | 27 | #include "base.h" 28 | #include "appstream/component.h" 29 | 30 | class XdgApplication : public Application 31 | { 32 | Q_OBJECT 33 | 34 | Q_PROPERTY(QString branch MEMBER m_branch CONSTANT) 35 | Q_PROPERTY(QString origin MEMBER m_origin CONSTANT) 36 | Q_PROPERTY(QString arch MEMBER m_arch CONSTANT) 37 | 38 | public: 39 | XdgApplication(XdgAppInstalledRef *app_ref, SoftwareBackend *backend); 40 | XdgApplication(Appstream::Component component, QString origin, SoftwareBackend *backend); 41 | 42 | QString installedVersion() const override { return m_branch; } 43 | 44 | QString latestVersion() const override { return "UNKNOWN"; } 45 | 46 | bool updatesAvailable() const override { return m_currentCommit != m_latestCommit; } 47 | 48 | QString m_branch; 49 | QString m_origin; 50 | QString m_arch; 51 | QString m_currentCommit; 52 | QString m_latestCommit; 53 | 54 | public slots: 55 | void install(); 56 | }; 57 | 58 | #endif // XDG_APPLICATION_H 59 | -------------------------------------------------------------------------------- /framework/xdg-app/xdg-backend.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * 4 | * Copyright (C) 2016 Michael Spencer 5 | * Copyright (C) 2015 Richard Hughes 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include "xdg-backend.h" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "xdg-remote.h" 27 | #include "xdg-application.h" 28 | #include "utils.h" 29 | 30 | #include "appstream/store.h" 31 | 32 | struct XdgAppHelper 33 | { 34 | XdgApplication *app; 35 | }; 36 | 37 | static void xdgAppChanged(GFileMonitor *monitor, GFile *child, GFile *other_file, 38 | GFileMonitorEvent event_type, XdgAppBackend *xdgapp) 39 | { 40 | emit xdgapp->updated(); 41 | } 42 | 43 | static void xdgAppProgressCallback(const char *rawStatus, uint progress, bool estimating, 44 | void *userData) 45 | { 46 | QString status = rawStatus; 47 | XdgAppHelper *helper = static_cast(userData); 48 | 49 | Q_ASSERT(helper->app); 50 | 51 | qDebug() << "Progress callback for" << helper->app->m_id << status << progress << estimating; 52 | // TODO: Do something more! 53 | } 54 | 55 | XdgAppBackend::XdgAppBackend(QObject *parent) : SoftwareBackend(parent) 56 | { 57 | // Nothing needed here yet. 58 | } 59 | 60 | void XdgAppBackend::initialize() throw(InitializationFailedException) 61 | { 62 | // Don't reinitialize 63 | if (m_installation != nullptr) 64 | return; 65 | 66 | // TODO: Do something with these 67 | GCancellable *cancellable = nullptr; 68 | GError *error = nullptr; 69 | 70 | m_installation = xdg_app_installation_new_user(cancellable, &error); 71 | 72 | if (m_installation == nullptr) 73 | throw InitializationFailedException(error); 74 | 75 | m_monitor = xdg_app_installation_create_monitor(m_installation, cancellable, &error); 76 | 77 | if (m_monitor == nullptr) 78 | throw InitializationFailedException(error); 79 | 80 | g_signal_connect(m_monitor, "changed", G_CALLBACK(xdgAppChanged), this); 81 | } 82 | 83 | QList XdgAppBackend::listSources() 84 | { 85 | initialize(); 86 | 87 | QList sources; 88 | 89 | // TODO: Do something with these 90 | GCancellable *cancellable = nullptr; 91 | GError *error = nullptr; 92 | 93 | g_autoptr(GPtrArray) xremotes = 94 | xdg_app_installation_list_remotes(m_installation, cancellable, &error); 95 | 96 | if (xremotes == nullptr) 97 | return sources; 98 | 99 | G_FOREACH (XdgAppRemote *xremote, xremotes) { 100 | sources << new Remote(xremote, this); 101 | } 102 | 103 | return sources; 104 | } 105 | 106 | QList XdgAppBackend::listAvailableApplications() 107 | { 108 | initialize(); 109 | 110 | QList applications; 111 | 112 | // TODO: Do something with these 113 | GCancellable *cancellable = nullptr; 114 | GError *error = nullptr; 115 | 116 | g_autoptr(GPtrArray) xremotes = 117 | xdg_app_installation_list_remotes(m_installation, cancellable, &error); 118 | 119 | if (xremotes == nullptr) 120 | return applications; 121 | 122 | G_FOREACH (XdgAppRemote *xremote, xremotes) { 123 | /* add the new AppStream repo to the shared store */ 124 | g_autoptr(GFile) file = xdg_app_remote_get_appstream_dir(xremote, NULL); 125 | QString appstreamFilename = g_file_get_path(file); 126 | 127 | QString origin = xdg_app_remote_get_name(xremote); 128 | 129 | qDebug() << "Using AppStream metadata found at: " << appstreamFilename << origin; 130 | 131 | Appstream::Store store; 132 | store.load(appstreamFilename); 133 | 134 | foreach (Appstream::Component component, store.allComponents()) { 135 | applications << new XdgApplication(component, origin, this); 136 | } 137 | } 138 | 139 | return applications; 140 | } 141 | 142 | QList XdgAppBackend::listInstalledApplications() 143 | { 144 | initialize(); 145 | 146 | QList applications; 147 | 148 | // TODO: Do something with these 149 | GCancellable *cancellable = nullptr; 150 | GError *error = nullptr; 151 | 152 | g_autoptr(GPtrArray) xrefs = 153 | xdg_app_installation_list_installed_refs(m_installation, cancellable, &error); 154 | 155 | if (xrefs == nullptr) 156 | return applications; 157 | 158 | G_FOREACH (XdgAppInstalledRef *xref, xrefs) { 159 | /* 160 | * Only show the current application in GNOME Software 161 | * 162 | * You can have multiple versions/branches of a particular app-id 163 | * installed but only one of them is "current" where this means: 164 | * 1) the default to launch unless you specify a version 165 | * 2) The one that gets its exported files exported 166 | */ 167 | qDebug() << xdg_app_installed_ref_get_is_current(xref); 168 | if (!xdg_app_installed_ref_get_is_current(xref) && 169 | xdg_app_ref_get_kind(XDG_APP_REF(xref)) == XDG_APP_REF_KIND_APP) { 170 | qDebug() << "Skipping!"; 171 | continue; 172 | } 173 | 174 | applications << new XdgApplication(xref, this); 175 | } 176 | 177 | return applications; 178 | } 179 | 180 | bool XdgAppBackend::launchApplication(const Application *app) 181 | { 182 | initialize(); 183 | 184 | const XdgApplication *xapp = qobject_cast(app); 185 | 186 | // TODO: Do something with these 187 | GCancellable *cancellable = nullptr; 188 | GError *error = nullptr; 189 | 190 | return xdg_app_installation_launch(m_installation, qPrintable(xapp->m_id), NULL, 191 | qPrintable(xapp->m_branch), NULL, cancellable, &error); 192 | } 193 | 194 | bool XdgAppBackend::downloadUpdates() 195 | { 196 | initialize(); 197 | 198 | GCancellable *cancellable = nullptr; 199 | GError *error = nullptr; 200 | 201 | /* get all the updates available from all remotes */ 202 | g_autoptr(GPtrArray) xrefs = xdg_app_installation_list_installed_refs_for_update( 203 | m_installation, cancellable, &error); 204 | 205 | if (xrefs == nullptr) 206 | throw GLibException("Unable to get list of updates", error); 207 | 208 | if (xrefs->len == 0) 209 | return false; 210 | 211 | qDebug() << "Downloading" << xrefs->len << "updates"; 212 | 213 | G_FOREACH (XdgAppInstalledRef *xref, xrefs) { 214 | XdgApplication *app = new XdgApplication(xref, this); 215 | 216 | XdgAppHelper helper = {app}; 217 | 218 | qDebug() << "Updating" << xdg_app_ref_get_name(XDG_APP_REF(xref)); 219 | XdgAppInstalledRef *xref2 = xdg_app_installation_update( 220 | m_installation, XDG_APP_UPDATE_FLAGS_NO_DEPLOY, 221 | xdg_app_ref_get_kind(XDG_APP_REF(xref)), xdg_app_ref_get_name(XDG_APP_REF(xref)), 222 | xdg_app_ref_get_arch(XDG_APP_REF(xref)), xdg_app_ref_get_branch(XDG_APP_REF(xref)), 223 | (XdgAppProgressCallback) xdgAppProgressCallback, &helper, cancellable, &error); 224 | if (xref2 == nullptr) { 225 | QString what = "Unable to download update for " + 226 | QString(xdg_app_ref_get_name(XDG_APP_REF(xref))); 227 | throw GLibException(qPrintable(what), error); 228 | } 229 | } 230 | 231 | return true; 232 | } 233 | 234 | bool XdgAppBackend::refreshAvailableApplications() 235 | { 236 | initialize(); 237 | 238 | // TODO: Do something with these 239 | GCancellable *cancellable = nullptr; 240 | GError *error = nullptr; 241 | 242 | g_autoptr(GPtrArray) xremotes = 243 | xdg_app_installation_list_remotes(m_installation, cancellable, &error); 244 | 245 | if (xremotes == nullptr) 246 | return false; 247 | 248 | G_FOREACH (XdgAppRemote *xremote, xremotes) { 249 | g_autoptr(GError) error_local = NULL; 250 | 251 | /* is the timestamp new enough */ 252 | // TODO: Figure this out 253 | // g_autoptr(GFile) file_timestamp = xdg_app_remote_get_appstream_timestamp(xremote, NULL); 254 | // uint file_age = gs_utils_get_file_age(file_timestamp); 255 | // if (file_age < cache_age) { 256 | // QString filename = g_file_get_path(file_timestamp); 257 | // qDebug() << filename << "is only" << file_age << "seconds old, so ignoring refresh"; 258 | // continue; 259 | // } 260 | 261 | /* download new data */ 262 | bool result = xdg_app_installation_update_appstream_sync( 263 | m_installation, xdg_app_remote_get_name(xremote), NULL, /* arch */ 264 | NULL, /* out_changed */ 265 | cancellable, &error_local); 266 | if (!result) { 267 | if (g_error_matches(error_local, G_IO_ERROR, G_IO_ERROR_FAILED)) { 268 | qDebug() << "Failed to get AppStream metadata:" << error_local->message; 269 | continue; 270 | } 271 | 272 | qWarning() << "Failed to get AppStream metadata, aborting:" << error_local->message; 273 | return false; 274 | } 275 | } 276 | 277 | qDebug() << "Finished updating applications!"; 278 | 279 | emit availableApplicationsChanged(); 280 | return true; 281 | } 282 | -------------------------------------------------------------------------------- /framework/xdg-app/xdg-backend.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XDG_BACKEND_H 20 | #define XDG_BACKEND_H 21 | 22 | #include "backend.h" 23 | 24 | #include 25 | #include 26 | 27 | #include "base.h" 28 | 29 | using namespace std; 30 | 31 | struct AppstreamSource 32 | { 33 | QString origin; 34 | QString appstreamFilename; 35 | }; 36 | 37 | class GLibException : public runtime_error 38 | { 39 | public: 40 | GLibException(const char *what, GError *error) : runtime_error(what), m_error(error) {} 41 | 42 | virtual const char *what() const throw() 43 | { 44 | QString error = runtime_error::what(); 45 | 46 | if (m_error != nullptr) { 47 | error = error + ": " + m_error->message; 48 | } 49 | 50 | return qPrintable(error); 51 | } 52 | 53 | private: 54 | GError *m_error; 55 | }; 56 | 57 | class InitializationFailedException : public GLibException 58 | { 59 | public: 60 | InitializationFailedException(GError *error) 61 | : GLibException("Unable to initialize xdg-app backend", error) 62 | { 63 | } 64 | }; 65 | 66 | class XdgAppBackend : public SoftwareBackend 67 | { 68 | Q_OBJECT 69 | 70 | public: 71 | XdgAppBackend(QObject *parent = nullptr); 72 | 73 | QList listSources() override; 74 | QList listAvailableApplications() override; 75 | QList listInstalledApplications() override; 76 | 77 | public slots: 78 | bool launchApplication(const Application *app) override; 79 | bool downloadUpdates() override; 80 | bool refreshAvailableApplications() override; 81 | 82 | private: 83 | void initialize() throw(InitializationFailedException); 84 | 85 | XdgAppInstallation *m_installation = nullptr; 86 | GFileMonitor *m_monitor = nullptr; 87 | QList m_appstreamPaths; 88 | }; 89 | 90 | #endif // XDG_BACKEND_H 91 | -------------------------------------------------------------------------------- /framework/xdg-app/xdg-remote.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef REMOTE_H 20 | #define REMOTE_H 21 | 22 | #include "source.h" 23 | 24 | #include 25 | #include 26 | 27 | #include "base.h" 28 | 29 | class Remote : public SoftwareSource 30 | { 31 | Q_OBJECT 32 | 33 | Q_PROPERTY(QString name MEMBER m_name CONSTANT) 34 | Q_PROPERTY(QString title MEMBER m_title CONSTANT) 35 | Q_PROPERTY(QString url MEMBER m_url CONSTANT) 36 | 37 | public: 38 | Remote(XdgAppRemote *remote, QObject *parent = nullptr) : SoftwareSource(parent) 39 | { 40 | m_name = xdg_app_remote_get_name(remote); 41 | m_title = xdg_app_remote_get_title(remote); 42 | m_url = xdg_app_remote_get_url(remote); 43 | } 44 | 45 | QString m_name; 46 | QString m_title; 47 | QString m_url; 48 | }; 49 | 50 | #endif // REMOTE_H 51 | -------------------------------------------------------------------------------- /notifier/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE SOURCES *.cpp *.h) 2 | 3 | add_executable(papyros-update-notifier ${SOURCES}) 4 | target_link_libraries(papyros-update-notifier 5 | Qt5::Core 6 | Papyros::Core 7 | Papyros::Software 8 | KF5::Notifications) 9 | 10 | install(TARGETS papyros-update-notifier 11 | DESTINATION ${CMAKE_INSTALL_BINDIR}) 12 | -------------------------------------------------------------------------------- /notifier/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "updatenotifier.h" 4 | 5 | #define TR(x) QT_TRANSLATE_NOOP("Command line parser", QStringLiteral(x)) 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | QCoreApplication app(argc, argv); 10 | app.setApplicationName("io.papyros.AppCenter"); 11 | app.setOrganizationDomain("papyros.io"); 12 | app.setOrganizationName("Papyros"); 13 | 14 | UpdateNotifier notifier; 15 | 16 | notifier.checkForUpdates(); 17 | 18 | return app.exec(); 19 | } 20 | -------------------------------------------------------------------------------- /notifier/updatenotifier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Papyros Software - The app store for Papyros 3 | * Copyright (C) 2016 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef BACKEND_H 20 | #define BACKEND_H 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | class UpdateNotifier : public QObject 29 | { 30 | Q_OBJECT 31 | 32 | public: 33 | UpdateNotifier(QObject *parent = nullptr) : QObject(parent) 34 | { 35 | m_softwareManager = new SoftwareManager(this); 36 | connect(m_softwareManager, &SoftwareManager::updatesDownloaded, this, 37 | &UpdateNotifier::updatesDownloaded); 38 | } 39 | 40 | public slots: 41 | void checkForUpdates() 42 | { 43 | qDebug() << "Checking for updates"; 44 | m_softwareManager->downloadUpdates(); 45 | } 46 | 47 | private slots: 48 | void updatesDownloaded() 49 | { 50 | bool hasUpdates = m_softwareManager->hasUpdates(); 51 | 52 | qDebug() << "Has updates" << hasUpdates; 53 | 54 | if (hasUpdates) { 55 | KNotification *notification = 56 | new KNotification("updatesAvailable", KNotification::Persistent, this); 57 | notification->setText(m_softwareManager->updatesSummary()); 58 | notification->setActions(QStringList(tr("Install updates"))); 59 | // connect(notification, SIGNAL(activated(unsigned int )), contact , 60 | // SLOT(slotOpenChat()) ); 61 | notification->sendEvent(); 62 | } 63 | } 64 | 65 | private: 66 | SoftwareManager *m_softwareManager = nullptr; 67 | }; 68 | 69 | #endif // BACKEND_H 70 | --------------------------------------------------------------------------------